W3C home > Mailing lists > Public > public-qt-comments@w3.org > September 2005

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

From: <bugzilla@wiggum.w3.org>
Date: Thu, 01 Sep 2005 00:43:26 +0000
To: public-qt-comments@w3.org
Cc:
Message-Id: <E1EAdAs-0005aQ-W6@wiggum.w3.org>

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&#8208;
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:08 UTC