Jump to content

Match Regular Expression doesn't match a null string


Recommended Posts

I've used the PCRE library for years in lots of contexts (including in LabVIEW back before 8.0). Based on that experience the attached code looks like a bug to me.

post-2992-1147185811.png?width=400

The regex ^$ should match a string that has nothing (the affirmative kind of nothing ;) ) anchored to both the beginning and end of the subject, i.e. the null string. But the LabVIEW Match Regular Expression function returns a match offset of -1. It seems to me it should return 0.

Maybe the -1 match offset is technically correct (because the subject string is length 0), but even if that's the case it seems like Match Regular Expression should return some indication that it matched successfully.

I really liked how the old PCRE LabVIEW returned a boolean for "Matched?" instead of just the match offset...

EDIT: OK, here's what I'm talking about.

post-2992-1147186400.png?width=400

This is the same subject and the same regex, but the old PCRE library returns a successful match, and also returns the proper (strictly speaking) null string in the substrings array.

Link to comment

Justin,

I'm surprised that nobody followed up on your posting, though I don't know what the 'correct' behavior is for the null length match situation you described. (It's sort of a 'pathological case'.)

However, I've recently been trying to use the new PCRE Match Regular Expression primitive, and I've found another behavior that I'd tentatively call a bug. It sure 'smells' like some kind of holdover from C string functions, since it involves null character matching (null, as in character value of 0x00).

Basically, I can't find any way to create a regex that will match to a character pattern which has a null character within it. The pattern matching always splits the input string at the nullchar, and if I include \x00 anywhere in the regex (to try to explicitly match the nullchar), the entire matching fails.

I don't have any Perl experience - can anyone else tell me if my assumptions are faulty here?

Best regards,

Dave

P.S. I can't identify the node in the diagram below - is/was it a primitive, or was it a VI that had a yellow icon? Can you tell me where to find it?

EDIT: OK, here's what I'm talking about.

post-2992-1147186400.png?width=400

This is the same subject and the same regex, but the old PCRE library returns a successful match, and also returns the proper (strictly speaking) null string in the substrings array.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.