#! /usr/bin/perl -w use strict; use locale; my $string = "_'na'da_komo_el_'sol_"; $string =~ s/(_)'?(\w)/$1'$2/g; print "$string\n";