Lookbehind assertions problem with 1.33
I'm trying to use lookbehind assertions, and here's a problem: the following syntax (?<=^.{2}).{4} gives me the error: '(?<=^.{2}).{4}' is a bad regular expression: Unmatched [ or [^ while the following works: (?<=^..).{4} matching, as I expected, 4 characters after the first 2 characters in a line. Shouldn't the above two regexes work the same way? Thanks, -Gregory __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
I'm trying to use lookbehind assertions, and here's a problem: the following syntax
(?<=^.{2}).{4}
gives me the error:
'(?<=^.{2}).{4}' is a bad regular expression: Unmatched [ or [^
while the following works:
(?<=^..).{4}
matching, as I expected, 4 characters after the first 2 characters in a line.
Shouldn't the above two regexes work the same way?
Probably, but the lookbehind assertion code is pretty dumb at present: it needs to be able to figure out exactly how many characters to look behind in advance, and currently bounded repeats aren't supported. It's probably not too hard to support that case, but it's too late for 1.33 I'm afraid. John.
Thanks. It's OK, I can use mutiple dots for now. I just wanted
to make sure that I didn't make a stupid mistake in
(?<=^.{2}).{4}
-Gregory
--- John Maddock
I'm trying to use lookbehind assertions, and here's a problem: the following syntax
(?<=^.{2}).{4}
gives me the error:
'(?<=^.{2}).{4}' is a bad regular expression: Unmatched [ or [^
while the following works:
(?<=^..).{4}
matching, as I expected, 4 characters after the first 2 characters in a line.
Shouldn't the above two regexes work the same way?
Probably, but the lookbehind assertion code is pretty dumb at present: it needs to be able to figure out exactly how many characters to look behind in advance, and currently bounded repeats aren't supported. It's probably not too hard to support that case, but it's too late for 1.33 I'm afraid.
John.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
I found another problem, this time, I'm afraid, without a workaround:
regex: (?<=^).{2}|(?<=^...).{2}
string: 1234567890
I get, using boost::regex, only one match:
12
whereas, for example, .Net Regex engine expectedly finds
12
and
45
Is this a bug? If so, any hopes for fixing it in 1.33?
Thank you,
-Gregory
--- John Maddock
I'm trying to use lookbehind assertions, and here's a problem: the following syntax
(?<=^.{2}).{4}
gives me the error:
'(?<=^.{2}).{4}' is a bad regular expression: Unmatched [ or [^
while the following works:
(?<=^..).{4}
matching, as I expected, 4 characters after the first 2 characters in a line.
Shouldn't the above two regexes work the same way?
Probably, but the lookbehind assertion code is pretty dumb at present: it needs to be able to figure out exactly how many characters to look behind in advance, and currently bounded repeats aren't supported. It's probably not too hard to support that case, but it's too late for 1.33 I'm afraid.
John.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
__________________________________ Yahoo! Mail Stay connected, organized, and protected. Take the tour: http://tour.mail.yahoo.com/mailtour.html
I found another problem, this time, I'm afraid, without a workaround:
regex: (?<=^).{2}|(?<=^...).{2} string: 1234567890
I get, using boost::regex, only one match:
12
whereas, for example, .Net Regex engine expectedly finds
12
and
45
Is this a bug? If so, any hopes for fixing it in 1.33?
Hmm, I guess it is a bug, and it's unfixable for 1.33 - it's too close to release for one thing, for another I don't know how to fix it at present: it happens because once the "12" match has been found, searching continues from "34567890", so the matcher doesn't "know" that there are preceding characters before that, that could be matched with the lookbehind. I'd have to start introducing new API's, and some new internals for the regex iterators in order to fix this :-( Thanks for the report, as soon as 1.33 is out I'll try and deal with this. John.
participants (2)
-
Gregory Nisnevich
-
John Maddock