LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in regular expression pattern matching?

When I have the string "testing" and a regular expression "test+ting" Labview gives a match substring "testing" and empty before and after substrings.

And my question is: Why?

I would think that this behaviour is for the special character "*" and that using "+" should only match to strings like "testting" and "testtttttting"?
0 Kudos
Message 1 of 7
(2,837 Views)
It does appear to be a bug. I tried it in 6.1 and 7.0. Since the first 't' is already matched by the 't+' the second 't' in the regex should not find its match.

- Dan
0 Kudos
Message 2 of 7
(2,837 Views)
The special character "+" is similar to "*" except there is to be at least one match of the preceding character. Therefore "test*ting" will match "testing" but "test+ting" won't. If you want to match for "testing" or "testting" use the pattern "testt?ing". "?" match for 0 or 1 occurence.


LabVIEW, C'est LabVIEW

0 Kudos
Message 3 of 7
(2,837 Views)
Jean-Pierre,

I agree 100%. The problem is that "test+ting" actually does match "testing", and it should not!

- Dan
0 Kudos
Message 4 of 7
(2,837 Views)
Yes. I figured out the real problem after hitting "submit"...


LabVIEW, C'est LabVIEW

0 Kudos
Message 5 of 7
(2,837 Views)
"Anthony de Vries" wrote:
> When I have the string "testing" and a regular expression "test+ting"
> Labview gives a match substring "testing" and empty before and after
> substrings.
>
> And my question is: Why?
>
> I would think that this behaviour is for the special character "*" and
> that using "+" should only match to strings like "testting" and
> "testtttttting"?

I agree. That's a bug. Good find. Did you report it to NI?

Just to verify, I ran the same test in the Perl 5.6.1 language, which is
designed for applications that use pattern matching expressions heavily. The
Labview Match Pattern regular expression syntax is a small subset of Perl's
syntax but should work identically, in a way that is standard across the many
languages t
hat use the common "regular expression" syntax.

Perl behaved as you would expect. No match was found for "testing", and
matches were found for "testting" and "testttttting".

Joe Czapski
Electronics Engineer
AutoMeasure
Boston, Mass.
Message 6 of 7
(2,837 Views)
Joe, Dan, Jean-Pierre,

Thanks for the feedback! I'll make a bug report for NI.

Anthony.
0 Kudos
Message 7 of 7
(2,837 Views)