LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match Regular Expression does not match what Match Pattern does

Solved!
Go to solution

I have read through a lot of posts about how Match Pattern does not match what Match Regular Expression will due to not processing some characters.

 

However, I found a problem with the other way. A simple Reg-Ex that works in Match Pattern but not Match Regular Expression.

 

What I have here is just an example. I want to use Match Regular Expression so I can specify some sub-matches.

 

The reg-ex is for: one or more non-numeric characters, a space, one or more numeric characters. At the start of the string.

 

How can I get this working in Match Regular Expression? I am working in LabVIEW 2010f2 32 bit. Here is the code snippet and the results:

 

RegEx vs Match Pattern.pngMatch Results.PNG

Rob

0 Kudos
Message 1 of 4
(3,383 Views)
Solution
Accepted by topic author RobCole

One of the subtle differences is the negation operator for character classes.  In Match Pattern it is ~, but for Match RegEx it is ^.

Message 2 of 4
(3,375 Views)

@Darin.K wrote:

One of the subtle differences is the negation operator for character classes.  In Match Pattern it is ~, but for Match RegEx it is ^.


Thank you Darin. I missed that little difference in the documentation. Everything else looks the same.

 

I think I prefer the ~ for negation since ^ is also used for beginning of the string. But we work with what we have.

 

Rob

0 Kudos
Message 3 of 4
(3,371 Views)

@Robert Cole wrote:

 

I think I prefer the ~ for negation since ^ is also used for beginning of the string. But we work with what we have.

 


Let me offer you a tip and perhaps defend the honor of the regex a little bit.  One of my favorite features of regexes is the ability to specify character classes (and their negation).  One of the reasons I have to think about the ~ versus ^ is that I rarely use ^ in a regex alternative. 

 

Some examples:

[0-9] = \d (digit)

[^0-9] = \D (not a digit)

 

The equivalent regex for your case is: \D+ \d+

 

0 Kudos
Message 4 of 4
(3,352 Views)