From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match Regular Expression won't work with Null

Is that right? I don't see it in the documentation. I can use it on \01 , just not \00.
 
Is there a way around this problem? I know that Match Pattern works, but I want to use it with separate partial matches (a|b) which Match Pattern does not support.
0 Kudos
Message 1 of 10
(5,877 Views)
Hi 10things,

What an odd little behavior.

If you look at the attached image, you'll see that the Null character is being found... sort of.  The offset past match value is *not* -1, which would indicate nothing found.  However, the null character is being returned in the after match output, not the whole match output.

Perhaps you can monitor the offset past match value rather than the whole match string, and do what you need when it's not negative?

2 cents,

Joe Z.
0 Kudos
Message 2 of 10
(5,865 Views)
It's not really working - try an input string that doesn't START with \00. It's just not reporting -1 like it should - so it's even more broken than I realized!
0 Kudos
Message 3 of 10
(5,854 Views)
Here's a possibility:

If you try to set the constant "\00" to "\0" with the '\' Code Display on, it just converts it back to "\00" on the display.

The function uses the PCRE library.  From the library documentation (the pcrepattern man page):

"After \0 up to two further octal digits are read. In both cases, if there are fewer than two digits, just those that are present are used. Thus the sequence \0\x\07 specifies two binary zeros followed by a BEL character (code value 7). Make sure you supply two digits after the initial zero if the pattern character that follows is itself an octal digit."

So, what if, behind the scenes, LV is actually feeding the match function just a "\0"?  I'm guessing (but haven't been able to verify) it would match *any* input string, immediately, with an offset of zero.  Testing with random search strings shows behavior that might indicate this.

If the above is true, getting around it might be hard, since you're at the mercy of LV as to exactly how it calls that library.

Fun stuff... okay, back to work with me.  Good luck,

Joe Z.


0 Kudos
Message 4 of 10
(5,840 Views)

The .(dot) operator in Labview 2009 can match any ASCII character including NULL or other non-displayable characters.

At least when Match Pattern.vi is used instead of Match Regular Expression.vi 

 

Lets say you are looking for the string 'A#C' (where # is any ASCII character) from a larger string. Using the regular expression 'A.C' will work.

 

 

0 Kudos
Message 5 of 10
(5,427 Views)
Minor point.  The"." will match any char EXCEPT newline \n

"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 10
(5,421 Views)

Actually, it will match a newline.

regex tomfoolery.PNG 

I know my regular expression reference says otherwise too, but it appears that the way the '.' operator works in Labview it will match anything.

Message Edited by Paul567 on 02-05-2010 02:07 PM
0 Kudos
Message 7 of 10
(5,399 Views)

dot.PNG

Correct operation in 2009f3


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 10
(5,384 Views)
Match Pattern behaves differently than  Match Regular Expression.  Bites me in the butt all-to-often.
0 Kudos
Message 9 of 10
(5,381 Views)

The difference between the two screenshots being one is using Match Pattern.vi and the other is using Match Regular Expression.vi.

 

Looks like if you have NULLs in your string, use Match Pattern, if not use Match Regular Expression. 

 

edit: 

Hey Jeff, think you can try Match Pattern instead of Match Regular Expression in your example? I want to see if this is something that got fixed or changed between the quarterly releases of 2009.

Message Edited by Paul567 on 02-05-2010 02:46 PM
0 Kudos
Message 10 of 10
(5,378 Views)