04-30-2018 01:52 AM
Hi. I've added a picture which illustrates my issue. I want to match strings of the format of 17-050550_auto_test.xlsx
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?
Solved! Go to Solution.
04-30-2018 02:06 AM
Hi Ola,
simple solution:
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!
04-30-2018 02:08 AM
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"?
04-30-2018 02:21 AM
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.
04-30-2018 04:45 AM
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/