in reply to Re: negative lookbehind and VERY strange capture
in thread negative lookbehind and VERY strange capture

Hello BrowserUK,

Thank you very much for your answer. I just learn something. I put « non-capturing parentheses » and it did the trick :

my $s = '"abcd"'; print "Try for \"$s\":\n"; if ($s =~ /^(?<!\\)"((?:(?<=\\)"|[^"])*)(?<!\\)"$/) { print "It matches!\n"; print '$1: ' . $1 . "\n"; print '$2: ' . (defined($2) ? "\$2 is defined\n" : "\$2 is NOT defin +ed\n"); } else { print "It does not match!\n"; }

However, as Corion pointed out, my regular expression does not work for this string « abcd\\ ». I’ll try some new approaches.

Best regards

Denis