What does this output? $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a' Cunning multilinguists may also answer the same question of these, (which nominally do the same thing) $ ruby -e 'p "aabbb".gsub(/b*$/, "c")' $ python -c "import re; print re.sub(r'b*$', 'c', 'aabbb')" Enjoy... Paul