[Bug 1922] 'x' regex flag not entirely clear

http://www.w3.org/Bugs/Public/show_bug.cgi?id=1922





------- Additional Comments From liam@w3.org  2005-09-01 00:43 -------
The Perl documentation is useful here (it had to happen once).

The "perldoc perlre" page says,
[[
The "/x" modifier itself needs a little more explanation.  It tells the
regular expression parser to ignore whitespace that is neither back‐
slashed nor within a character class.  You can use this to break up
your regular expression into (slightly) more readable parts.  The "#"
character is also treated as a metacharacter introducing a comment,
just as in ordinary Perl code.  This also means that if you want real
whitespace or "#" characters in the pattern (outside a character class,
where they are unaffected by "/x"), that you'll either have to escape
them or encode them using octal or hex escapes.  Taken together, these
features go a long way towards making Perl's regular expressions more
readable. 
]]

I believe this is a sensible and appropriate definition, and
means that [ ] matches a single space (and also, for Perl,
that you can't put comments inside character classes).

It's not clear to me how to allow host-language comments
inside a regular expression, and I think that should be up
to the host language to specify, rather than using Perl's
# comments.  So just take the whitespace part of this.

Liam

Received on Thursday, 1 September 2005 00:43:30 UTC