LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching for the '$' character in a regex

Solved!
Go to solution

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

0 Kudos
Message 1 of 11
(5,496 Views)

Have you tried this:

 

regex.png

0 Kudos
Message 2 of 11
(5,483 Views)

Hi Michael, As I said above, trying to escape it using backslash doesn't work - it still gets interpreted as the $ command character

0 Kudos
Message 3 of 11
(5,476 Views)

Can you send an example? The escape character is working in the simple example above.

 

Michel

0 Kudos
Message 4 of 11
(5,470 Views)
Solution
Accepted by topic author McV

I think we have it working...

\\$\s[\n\r]

seems to do the trick

0 Kudos
Message 5 of 11
(5,452 Views)

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

0 Kudos
Message 6 of 11
(5,448 Views)

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

0 Kudos
Message 7 of 11
(5,440 Views)

@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

 

http://www.regexr.com/

 

 

Also, Michel_Gauvin solution works in LabVIEW 2013.

 

 

0 Kudos
Message 8 of 11
(5,427 Views)

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..

0 Kudos
Message 9 of 11
(5,397 Views)

I assume you had the '\' Codes display mode active in your regex string.

'\$ ' becomes '\\$\s' in that display format.

 

0 Kudos
Message 10 of 11
(5,385 Views)