ykar has asked for the wisdom of the Perl Monks concerning the following question:
Output is following:$a = qr{\QHello# World\E}x; $b = qr{Hello\#\ World}x; $test = "Hello# World"; $test =~ $a && print "\$a matches \$test\n"; $test =~ $b && print "\$b matches \$test\n"; print "\$a = $a\n\$b = $b\n";
$b matches $test $a = (?x-ism:Hello\#\ World\\E) $b = (?x-ism:Hello\#\ World)Why regular expressions $a and $b are not the same?
In perlre said that \Q and \E should quote white space and "#" character. It actually quotes the "#" character, but it quotes absolutely everything (even \E) after the "#" character.
Thank you very much for your attention!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weird quoting with /x modifier
by proceng (Scribe) on May 29, 2010 at 20:20 UTC | |
by proceng (Scribe) on May 29, 2010 at 22:40 UTC | |
by ykar (Acolyte) on May 29, 2010 at 22:25 UTC | |
|
Re: Weird quoting with /x modifier
by choroba (Cardinal) on May 29, 2010 at 18:37 UTC | |
by ykar (Acolyte) on May 29, 2010 at 22:34 UTC | |
|
Re: Weird quoting with /x modifier
by ikegami (Patriarch) on May 31, 2010 at 03:42 UTC | |
by ykar (Acolyte) on May 31, 2010 at 08:24 UTC | |
by ikegami (Patriarch) on May 31, 2010 at 15:40 UTC | |
|
Re: Weird quoting with /x modifier
by QM (Parson) on Nov 01, 2013 at 10:19 UTC |