in reply to Getting characters from regex pattern
This does the transformation you asked for but I'm not sure it meets your readability requirement. Certainly not the way I'd parse tokens out of a string.
$string="glarch capri foobar"; $r=q/Capri|Classic/; $string=~m/($r)/i; $r=~m/($1)/i; print $1; ... Returns 'Capri'
|
---|