diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1998-05-14 23:11:05 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-05-14 23:11:05 +0000 |
commit | 7b8d334a971230040a212bc5038097b3f600a094 (patch) | |
tree | e0fd6231e06e9b8f7e54aae4cec4ead51585219a /pod/perlre.pod | |
parent | 6ee623d521a149edc6574c512fa951a192cd086a (diff) | |
download | perl-7b8d334a971230040a212bc5038097b3f600a094.tar.gz |
[win32] merge change#897 from maintbranch
p4raw-link: @897 on //depot/maint-5.004/perl: f06f9b6fc5a686f0169ee2a91b32d5e7125a44ae
p4raw-id: //depot/win32/perl@974
Diffstat (limited to 'pod/perlre.pod')
-rw-r--r-- | pod/perlre.pod | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/pod/perlre.pod b/pod/perlre.pod index 95da75d95f..f029cbecc1 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -34,6 +34,13 @@ line anywhere within the string, Treat string as single line. That is, change "." to match any character whatsoever, even a newline, which it normally would not match. +The /s and /m modifiers both override the C<$*> setting. That is, no matter +what C<$*> contains, /s (without /m) will force "^" to match only at the +beginning of the string and "$" to match only at the end (or just before a +newline at the end) of the string. Together, as /ms, they let the "." match +any character whatsoever, while yet allowing "^" and "$" to match, +respectively, just after and just before newlines within the string. + =item x Extend your pattern's legibility by permitting whitespace and comments. @@ -139,7 +146,7 @@ also work: \Q quote (disable) regexp metacharacters till \E If C<use locale> is in effect, the case map used by C<\l>, C<\L>, C<\u> -and <\U> is taken from the current locale. See L<perllocale>. +and C<\U> is taken from the current locale. See L<perllocale>. In addition, Perl defines the following: @@ -238,7 +245,7 @@ non-alphanumeric characters: $pattern =~ s/(\W)/\\$1/g; Now it is much more common to see either the quotemeta() function or -the \Q escape sequence used to disable the metacharacters special +the C<\Q> escape sequence used to disable all metacharacters' special meanings like this: /$unquoted\Q$quoted\E$unquoted/ @@ -278,14 +285,15 @@ matches a word followed by a tab, without including the tab in C<$&>. A zero-width negative lookahead assertion. For example C</foo(?!bar)/> matches any occurrence of "foo" that isn't followed by "bar". Note however that lookahead and lookbehind are NOT the same thing. You cannot -use this for lookbehind. If you are looking for a "bar" which isn't preceeded -"foo", C</(?!foo)bar/> will not do what you want. That's because -the C<(?!foo)> is just saying that the next thing cannot be "foo"--and -it's not, it's a "bar", so "foobar" will match. You would have to do -something like C</(?!foo)...bar/> for that. We say "like" because there's -the case of your "bar" not having three characters before it. You could -cover that this way: C</(?:(?!foo)...|^.{0,2})bar/>. Sometimes it's still -easier just to say: +use this for lookbehind. + +If you are looking for a "bar" which isn't preceded by a "foo", C</(?!foo)bar/> +will not do what you want. That's because the C<(?!foo)> is just saying that +the next thing cannot be "foo"--and it's not, it's a "bar", so "foobar" will +match. You would have to do something like C</(?!foo)...bar/> for that. We +say "like" because there's the case of your "bar" not having three characters +before it. You could cover that this way: C</(?:(?!foo)...|^.{0,2})bar/>. +Sometimes it's still easier just to say: if (/bar/ && $` !~ /foo$/) |