10-22-2015 08:04 AM
I'm trying to use the 'Match Regular Expression' vi, but what I'm trying to find is a dollar symbol followed by a space.
Using slash codes allows me to specify a whitespace character (\s) but I can't find how to specify the $.
I've tried \x24 and \36 to try hex & decimal representations of ASCII, but no luck, I've tried putting the $ in square brackets - but that doesn't work either.
Whatever I try, the $ gets interpreted as a command rather than the search term.
I used to use match pattern (legacy code) and the search term '$\s*$' worked - now need to use regex as I need to feed in some other matches that only regex can do - except for the dollar (if only I was working in good old UK £ !)
Any ideas out there?
Thanks
Solved! Go to Solution.
10-22-2015 08:13 AM
Have you tried this:
10-22-2015 08:17 AM
Hi Michael, As I said above, trying to escape it using backslash doesn't work - it still gets interpreted as the $ command character
10-22-2015 08:20 AM
Can you send an example? The escape character is working in the simple example above.
Michel
10-22-2015 08:29 AM
I think we have it working...
\\$\s[\n\r]
seems to do the trick
10-22-2015 08:33 AM
I agree with Michel (in LabVIEW 2015). The RegEx "\$ " (without the quotes, of course) found the "dollar-sign+space" in a string just fine for me. Something is screwy with your example -- please post code (a VI, not a picture).
Bob Schor
10-22-2015 08:39 AM
I guess that one of the challenges is that I'm still using 2010 - maybe there is a fix in the intervening 5 years!
For the moment I'll run with this, as there are some people awfully keen to see the line running again...
Thanks guys
10-22-2015 08:57 AM - edited 10-22-2015 09:14 AM
@McV wrote:
I think we have it working...
\\$\s[\n\r]
seems to do the trick
\\$\s[\n\r]
does not make sense in regex for what you are trying to do
\\ means you are looking for a backslash
the $ matches the end of the string
then a space
then a newline carriage return
Also, Michel_Gauvin solution works in LabVIEW 2013.
10-22-2015 11:05 AM
I got doubly messed up there....
I'm now back to a solution I tried earlier, that didn't seem to work at the time..
[$]\s*$
So - looking for a dollar character followed by a space at the end of the string....This form seems to work with pattern match AND regex
Basically, I'm looking at the output of a serial port console, waiting for a unit to finish booting - lots of debug info is displayed first,
then a welcome banner and finally a $\s - at which pointy I can carry on..
10-22-2015 11:15 AM
I assume you had the '\' Codes display mode active in your regex string.
'\$ ' becomes '\\$\s' in that display format.