s/(".*?")/($x=$1)=~y: :_:, $x/ge) [CUT] =~y: :_:, '=~y: :_:, ' ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- x/ge 'x/ge'