From 7b059540b116737402869fbccad6d5c540c7f62e Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 25 Feb 2010 13:41:10 -0700 Subject: [PATCH] Mention there are places /x modifier is ineffective --- pod/perlfaq6.pod | 6 +++--- pod/perlre.pod | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pod/perlfaq6.pod b/pod/perlfaq6.pod index 4074526..40965d0 100644 --- a/pod/perlfaq6.pod +++ b/pod/perlfaq6.pod @@ -33,9 +33,9 @@ comments. =item Comments Inside the Regex The C modifier causes whitespace to be ignored in a regex pattern -(except in a character class), and also allows you to use normal -comments there, too. As you can imagine, whitespace and comments help -a lot. +(except in a character class and a few other places), and also allows you to +use normal comments there, too. As you can imagine, whitespace and comments +help a lot. C lets you turn this: diff --git a/pod/perlre.pod b/pod/perlre.pod index f98fba7..37cb6fc 100644 --- a/pod/perlre.pod +++ b/pod/perlre.pod @@ -82,20 +82,24 @@ modifiers may also be embedded within the regular expression itself using the C<(?...)> construct. See below. The C modifier itself needs a little more explanation. It tells -the regular expression parser to ignore whitespace that is neither +the regular expression parser to ignore most 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 C<#> 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 C<#> characters in the pattern (outside a character class, where they are unaffected by C), then you'll either have to -escape them (using backslashes or C<\Q...\E>) or encode them using octal -or hex escapes. Taken together, these features go a long way towards +escape them (using backslashes or C<\Q...\E>) or encode them using octal, +hex, or C<\N{}> 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 L. Also note that anything inside -a C<\Q...\E> stays unaffected by C. +a C<\Q...\E> stays unaffected by C. Also note that space is never allowed +within a L such as C<{3}> or C<{5,}>, regardless of +C, nor is space allowed before the C<{> or within the braces in C<\x{...}> +nor C<\N{U+...}>. Similarly space is not allowed before the C<{> in +C<\N{I}> and is currently significant within the braces. X =head2 Regular Expressions -- 2.7.4