How can I check if the string contains a real or integer number, space and string?
e.g.
StrCheck["156 af"] = true
StrCheck["15.6 af"] = true
StrCheck["a 156 af"] = false
StrCheck["a 1.56 af"] = false
Thank you!
How can I check if the string contains a real or integer number, space and string?
e.g.
StrCheck["156 af"] = true
StrCheck["15.6 af"] = true
StrCheck["a 156 af"] = false
StrCheck["a 1.56 af"] = false
Thank you!
f = StringMatchQ[#, NumberString ~~ " " ~~ __] &;
f /@ {"156 af", "15.6 af", "a 156 af", "a 1.56 af"}
{True, True, False, False}
See StringMatchQ, StringExpression, NumberString, BlankSequence, Slot, Function
Related: How can I improve NumberString?