>>>>> "SHC" == Shawn H Corey <[email protected]> writes:
SHC> On 10-12-27 06:30 PM, Uri Guttman wrote:
>> yes, you have misunderstood it. where did you read or learn that /x
>> ignores whitespace in the data?
SHC> He probably got the idea since other non-alphanumeric characters in a
SHC> variable must be escaped; un-escaped ones act like meta-characters.
that doesn't make any sense regarding the use of /x.
from perlretut (which ALL regex newbies should read):
Long regexps like this may impress your friends, but can be hard
to decipher. In complex situations like this, the "//x"
modifier for a match is invaluable. It allows one to put nearly
arbitrary whitespace and comments into a regexp without
affecting their meaning. Using it, we can rewrite our
'extended' regexp in the more pleasing form
looks pretty clear to me that means whitespace in the regex
itself. nothing to do with escaping or meta chars. also there are
non-alphanumerics that aren't metachars in regexes.
perlre has this longer part on /x:
The "/x" modifier itself needs a little more explanation. It
tells the regular expression parser to ignore whitespace that is
neither backslashed 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"), then you'll either have to escape them
(using backslashes or "\Q...\E") or encode them using octal or
hex escapes. Taken together, these features go a long way
towards making Perl's regular expressions more readable. Note
that you have to be careful not to include the pattern delimiter
in the comment--perl has no way of knowing you did not intend to
close the pattern early. See the C-comment deletion code in
perlop. Also note that anything inside a "\Q...\E" stays
unaffected by "/x".
that does mention escaping whitespace to make it signifigant under
/x. but it clearly states the regex parser and no where does it talk
about whitespace in the data being ignored.
so my question is still valid, where and how did the OP mistakenly learn
that /x ignores whitespace in the data being matched?
uri
--
Uri Guttman ------ [email protected] -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/