Justin Goeres Posted May 9, 2006 Report Share Posted May 9, 2006 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. 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. 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. Quote Link to comment
David Boyd Posted May 12, 2006 Report Share Posted May 12, 2006 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. 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. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.