in reply to Re: Unexpected behaviour of /x Regexp modifier?
in thread Unexpected behaviour of /x Regexp modifier?

Hi, you can easily capture spaces literally in \Q ... \E expressions, they are unaffected by /x, see http://perldoc.perl.org/perlre.html#Modifiers
perl -le ' print scalar localtime; $_=scalar localtime; /^\QMon Mar \E (\d+) \s (\d+) : (\d+) : (\d+) \s (\d+)/x; print "$1 $2-$3-$4 $5" ' Mon Mar 16 21:22:30 2009 16 21-19-13 2009

print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});

Replies are listed 'Best First'.
Re^3: Unexpected behaviour of /x Regexp modifier?
by johngg (Canon) on Mar 17, 2009 at 10:47 UTC

    Another way to do that is to turn x off for part of the pattern, either by toggling it, / ... (?-x)Mon Mar (?x) ... /x, or by localising the effect inside parentheses, / ... (?-x:Mon Mar ) ... /x. The technique can also be used for the i flag and, I think though I've never tried it, for s and m as well.

    I hope this is of interest.

    Cheers,

    JohnGG