Bug in regular expression pattern matching? 
Author Message
 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"?



Fri, 16 Dec 2005 21:25:37 GMT  
 Bug in regular expression pattern matching?
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



Fri, 16 Dec 2005 21:32:59 GMT  
 Bug in regular expression pattern matching?
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.


Fri, 16 Dec 2005 23:12:37 GMT  
 Bug in regular expression pattern matching?
Jean-Pierre,

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

 - Dan



Fri, 16 Dec 2005 23:32:20 GMT  
 Bug in regular expression pattern matching?

Quote:
> 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 that 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.



Sat, 17 Dec 2005 00:05:17 GMT  
 Bug in regular expression pattern matching?
Yes. I figured out the real problem <i>after</i> hitting "submit"...


Fri, 16 Dec 2005 23:43:14 GMT  
 Bug in regular expression pattern matching?
Joe, Dan, Jean-Pierre,

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

Anthony.



Sat, 17 Dec 2005 15:16:25 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. iss-matching - the free Regular Expression / Pattern Matching cluster

2. Regular Expression for Match Pattern (string) Function

3. Regular expression string pattern matching: Embedding pop-11 procedures, and more

4. Pattern-matching regular-expression algorithm?

5. Regular Expression Pattern Matching "State" Object

6. Regular expressions, pattern matching

7. pattern matching using regular expressions

8. regular expression matching in J ? (or APL)

9. Regular Expression to match HTML elements

10. regular expression: matching ( )

11. Regular expression matching with Halstenbach's REGEXP

12. Binding style and the universality of REs (was: Regular Expression Matching)

 

 
Powered by phpBB® Forum Software