in reply to matching a line with ' and "
You could use a character class and a back reference instead of alternation.
or using perl 5.10my $string = qq{var1='1' var2="2" var3="3"}; while ( $string =~ /(\w+)=(['"])(.*?)\2/g) { print "$1 = $3\n"; }
use 5.010_000; while ( $string =~ /(?<variable>\w+)=(?<delim>['"])(?<value>.*?)\k<del +im>/g) { say "$+{variable} = $+{value}"; }
In Section
Seekers of Perl Wisdom