Denis.Beurive has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I am using « negative lookbehind » pattern matching, and I get a very strange result.
Here is the simple code:
use strict; use warnings; my $s = '"toto"'; if ($s =~ /^(?<!\\)"(((?<=\\)"|[^"])+)(?<!\\)"$/) { print "It matches!\n"; print $1 . "\n"; print $2 . "\n"; }
And this is the result:
It matches! toto o
????
Where does the « o » come from ?
Any idea ?
Best regards
Denis
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: negative lookbehind and VERY strange capture
by Corion (Patriarch) on Sep 18, 2016 at 11:17 UTC | |
by Denis.Beurive (Initiate) on Sep 18, 2016 at 12:15 UTC | |
by hippo (Archbishop) on Sep 18, 2016 at 16:12 UTC | |
by AnomalousMonk (Archbishop) on Sep 18, 2016 at 18:31 UTC | |
|
Re: negative lookbehind and VERY strange capture
by BrowserUk (Patriarch) on Sep 18, 2016 at 11:22 UTC | |
by Denis.Beurive (Initiate) on Sep 18, 2016 at 11:53 UTC | |
|
Re: negative lookbehind and VERY strange capture
by BillKSmith (Monsignor) on Sep 18, 2016 at 12:26 UTC | |
|
Re: negative lookbehind and VERY strange capture
by Denis.Beurive (Initiate) on Sep 18, 2016 at 11:31 UTC |