03-16-2011 06:49 AM - edited 03-16-2011 06:52 AM
I seem to have found a bug in MatchPattern in LabVIEW 2010 when upgrading code from LabVIEW 8.2.1. Please refer to attached snippet to see more of the details.
With an input string of "RDB\tE\n..." and a search pattern of "[^\r\n]+" I would expet the result to be "RDB\tE" but it really is simply "RDB". This is quite a serious bug as it can render many string syntax parsers invalid. Of course PCRE is a workaround for now, but the help of the PCR function says explicitedly that it is slower in performance than the Match Pattern function.
Windows XP SP3, LabVIEW 2010 SP1
03-17-2011 01:05 PM - edited 03-17-2011 01:06 PM
Correct me if I am wrong, but I believe the [^] construct in Match Pattern returns displayable characters, of which \t is not.
My opinion is annoying, but not a bug in LV10. Certainly going to bite someone in the arse. Particularly nasty that it worked (incorectly) in LV8.2 apparently, I hate bug "fixes" that fix bugs you had no idea existed.
Personally, I have bitten the bullet and use PCRE almost exclusively.
I agree there is a bug here, a LV8.2 bug.
03-17-2011 01:26 PM
By the way the [~] construct also returns non-displayable characters, this is what you should be using here.
Half of the time I foul up my PCRE regexes by screwing up the ^ and ~, one reason I am starting to stick to one.
03-17-2011 02:10 PM - edited 03-17-2011 02:12 PM
Match Pattern is Regex similar but not the same. This is what the online help in LabVIEW 7.1 had to say about the ^ character when in brackets:
^ | Matches any displayable character, including the space and tab characters, except the characters or range of characters enclosed in the brackets. For example, [^0-9] matches all displayable characters, including the space and tab characters, except 0 through 9. |
Emphasis is mine.
So I still believe it is a bug in 2010!
03-17-2011 02:16 PM
LV9 Help for ^ inside []:
Matches any displayable character, including the space character, except the characters or range of characters enclosed in the brackets. For example, [^0-9] matches all displayable characters, including the space character, except 0 through 9.
Lack of emphasis shows lack of 'tab'.
I agree that it is devious to change behavior, but it is hard to say bug when the behavior matches the documentation. That is usually all I ask.
03-17-2011 02:50 PM
Yes I just checked. Seems the documentation was changed in LabVIEW 8.2 and then the functionality was changed to match the documentation in 8.5. And devious it is for sure!!