I need to extract a substring and an integer value from strings like 'abc12'.
If I use as format string '%s%d' Labview gives an error 85 (instead of expected two outputs:'abc' and 12)
Strangely (for me) everything seems to work fine using '%[a-z]%d' as format string
What's going wrong? Is it a bug or am I missing something?
I guess that %s actually sucks up the whole input and no chars remain for the %d.
Without a proper separator, the function cannot distinguish the two
inputs we human can see so clearly. abc12 is a string as good as abc.
On the other hand, the regular expression "knows" that the first part of the string stops when a digit is found.
Paolo
Paolo ------------------- LV 7.1, 2011, 2017, 2019, 2021
I admit. I have some problems with regular expressions. It's not the first time they put me in trouble.
By the way, your explanation is clear (almost obvious).
From this point of view, seems that charachter 'space' is the separator
you are talking about (a sort of default separator); in fact the input
string 'abc 12', using '%s%d' as format string, is splitted in 'abc' and 12.
However I cannot find any information about this in the Labview Help section.
Heres a snip from the help file just for reference which sheds some light on the subject:
Use the following conversion codes for a string:
s—String (for example, abc). When scanning, s matches only up to the next white-space character. A space matches one or more consecutive white-space characters. To scan a string that may contain white space, use the characters in set conversion code. Specify all the characters which the string may contain within the brackets, including space or other white-space characters.
[ ]—Characters in set. [ ] matches a string that contains only the characters specified between the brackets. Character matches are case sensitive. The [ ] conversion code is useful only when you are scanning strings. To match the caret symbol (^) in a set, make sure it is not the first character after the bracket.
The following examples demonstrate the use of the characters in set conversion code:
%[aeiou]—Matches any string that contains only lowercase vowels.
%[0-9a-zA-Z ]—Matches a string that contains numbers, letters, or spaces. You can use a hyphen to specify ranges of characters in the set.
%[^,;]—Matches any string of characters up to but not including the first comma or semicolon.
To match a hyphen, specify it as the first or last character in the set.