Regex teaser

Paul Makepeace paulm at paulm.com
Tue Dec 3 23:54:31 GMT 2013


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


More information about the london.pm mailing list