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


in reply to Modifying the match position after each match

#! /usr/bin/perl -w use strict; use locale; my $string = "_'na'da_komo_el_'sol_"; $string =~ s/(_)'?(\w)/$1'$2/g; print "$string\n";
Output: _'na'da_'komo_'el_'sol_ Why even bother capturing the single quotes in the string that are were you want them when you're going to insert them anyway?