in reply to Another puzzled RegEx Problem.

Lookbehind has to be a fixed width; yours isn't (the + quantifier) so it's an invalid regex.

This is a little kludgy, but will work:

my $str = "123456789"; $str = reverse $str; $str =~ s/(?<=\d)(?=(\d\d)+$)/-/g; $str = reverse $str; print $str, "\n";