in reply to Named capture backreferences cannot be used in character classes?
One workaround is to use a negative look-ahead plus a dot instead of a negated character class:
use strict; use warnings; use 5.010; for (qw/'abc' "abc" 'abc"/) { if (/(?<FQ>['"])(?<content>(?:(?!\k<FQ>).)+)\k<FQ>/s) { say $+{content}; } else { say "Not matched: $_"; } } __END__ abc abc Not matched: 'abc"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Named capture backreferences cannot be used in character classes?
by BrowserUk (Patriarch) on Sep 26, 2013 at 17:45 UTC | |
Re^2: Named capture backreferences cannot be used in character classes?
by Anonymous Monk on Sep 26, 2013 at 22:49 UTC |
In Section
Seekers of Perl Wisdom