I have a regex:
/abc(def)ghi(jkl)mno(pqr)/igs
How would I capture the results of each parentheses into 3 different variables, one for each
@OP, when parenthesis are captured, you can use the variables $1,$2....these are backreferences
$string="zzzabcdefghijklmnopqrsssszzzabcdefghijklmnopqrssss"; while ($string =~ /abc(def)ghi(jkl)mno(pqr)/isg) { print "$1 $2 $3\n"; }
output
$ perl perl.pl def jkl pqr def jkl pqr