I think (mostly because I've only been following this thread from the sidelines) that this won't "work" if there is no underscore at the end of the string:
#! /usr/bin/perl -w use strict; use locale; for my $s ( @{[ "_'nada_komo_el_'sol_", "_na'da_komo_el_so'l_", "_na'da_komo_el_sol" ]} ) { print $s; $s =~ s/(_)([^'][^_]+?)/$1'$2/g; print " : $s\n"; } __END__ > perl -w tmp.pl _'nada_komo_el_'sol_ : _'nada_'komo_'el_'sol_ _na'da_komo_el_so'l_ : _'na'da_'komo_'el_'so'l_ _na'da_komo_el_sol : _'na'da_'komo_'el_'sol
My solution would be to use a zero-width lookahead to ensure but not match the following underscore:
$s =~ s/(_)([^_']+?)(?=_)/$1'$2/g;
... but again, as I haven't been closely following, I'm not sure where my approach will fail the specifications.
In reply to Re^4: Modifying the match position after each match
by Corion
in thread Modifying the match position after each match
by pat_mc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |