annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

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

Risolto!
Vai alla soluzione

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
Messaggio 1 di 5
4.306Visualizzazioni
Soluzione
Accettato da 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
Messaggio 2 di 5
4.297Visualizzazioni

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"?

Messaggio 3 di 5
4.294Visualizzazioni

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
Messaggio 4 di 5
4.282Visualizzazioni

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/

Messaggio 5 di 5
4.255Visualizzazioni