LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW regex syntax question. /d{2} not equal to [0-9][0-9]

Solved!
Go to solution

Hi. I've added a picture which illustrates my issue. I want to match strings of the format of 17-050550_auto_test.xlsx

 

Capture.PNG

 

LabVIEW won't find the match using this syntax:

/d{2}-/d{6}_auto_test.xlsx

 

So I have to use this dirty, dirty, abominable solution:
[0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]_auto_test.xlsx

 

Which makes me sad. What's wrong with the first one? Which part does LabVIEW not accept?

0 Kudos
Message 1 of 5
(3,119 Views)
Solution
Accepted by topic author OlaMelien

Hi Ola,

 

simple solution:

check.png

 

Which makes me sad.

It makes me sad to get just an image instead of an example VI. This way we have to recreate your problem instead of debugging your VI…

 

Did you read the help for MatchPattern? It says:

The Match Pattern function is compatible with a limited set of regular expressions and does not support character grouping, alternate pattern matching, backreferences, or non-greedy quantification.

But there is a string function dedicated to RegEx: MatchRegularExpression!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(3,110 Views)

I recommend to attach a Vi instead of screenshots. We cannot run or debug pictures and recreating the code from scratch is lengthy and error prone. We won't do that!

 

What happens if you substitute "match regular expression" for "match pattern"?

Message 3 of 5
(3,107 Views)

Yeah I see now I should have uploaded the VI, but I thought it was easier with an image. I was wrong of course, when I think about it again. Sorry about that.

 

I think I'll stick with the solution using multiple [0-9]'s. Match Regular Expression doesn't like my expression either. At least the first one works, it just wasn't pretty to look at.

 

Thanks for the help.

0 Kudos
Message 4 of 5
(3,095 Views)

There is an error in your expression. For the expression to work it has to be: 

(\d{2})-(\d{6})_auto_test\.xlsx

 

Look at the use of \ vs. /, they have a different purepus in regular expression compared to Format in string. 

I have also grouped your numbers, so that your can extract them. 

You can always test your expression at: https://regexr.com/

Message 5 of 5
(3,068 Views)