[Issue 7551] Regex parsing bug for right bracket in character class

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 27 00:45:02 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7551



--- Comment #2 from Magnus Lie Hetland <magnus at hetland.org> 2012-02-27 00:44:59 PST ---
It did exist in the previous version -- my code broke with the new regexp
engine, but worked before :-)

If this is a conscious choice, then that's totally fine by me. Special cases
aren't the right way to go when the general mechanism works. I had some trouble
getting this to work (did something like what you wrote here, which won't work
-- but double-escaping does, of course), so I ended up with using the
or-operator, which was kind of hackish ;-)

So, yeah, I guess I "retract" my bug report :->

As for other languages: Yeah, I think this is pretty common. E.g., Python
(http://docs.python.org/library/re.html) and in Perl and Perl-compatible
regexps, as used in all kinds of places, such as PHP, Apache, Safari, …
(http://www.php.net/manual/en/regexp.reference.character-classes.php).

So I think the "place member end brackets as first character" is the "industry
standard" behavior.

But as a compromise: Perhaps a useful error message pointing out the escape
thing could be added? Or it could be explicitly pointed out in a note in the
documentation (to avoid special-casing the error code)?

I think some kind of "least surprise" handling for people coming from basically
anywhere else might be useful ;-)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list