http://www.perlmonks.org?node_id=1001018


in reply to Regex help/ Lua parse

You could save yourself one match by replacing
if ($line =~ m/^\s*terminal\s=\s"([^"]+)"\s*$/) { $line =~ s/$1/$change/; }
with
$line =~ s/^(\s*terminal\s=\s")([^"]+)("\s*)$/$1$change$3/;