But that's not usually a good idea.#!/your/perl/here use strict; use warnings; my $one = q/in ('X')/; my $two = q/in ('X','Y')/; my $three = q/in ('X','Y','Z')/; foreach my $s ( $one, $two, $three ) { our $r=''; (my $u = $s) =~ s{ # open regex - curly delimiters in\s+ \( # literal open paren (?: # non-capturing group ' # literal single quote ( # capture group [^'] # single non-single-quote-char ) # close capture group (?{$r=$r.$^N}) ' # literal single quote ) # closing non-capture group (?: # opening non-capture group ,' # literals ( # capture group [^'] # single non-single-quote-char ) # close capture group (?{$r=$r.$^N}) ' # literal single-quote )* # close non-capture group \) # literal close paren } # close regex - curly delimiter {=~\ m/\[$r\]}x; print "$s\n$u\n\n"; }
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re^2: Yet another regex question
by QM
in thread Yet another regex question
by gregor-e
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |