simon at simon-cozens.org
Wed Dec 4 01:02:10 GMT 2013
On 04/12/2013 08:54, Paul Makepeace wrote:
> $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
Why... oh. That's clever. Yes.
For those like me who are slow and can't immediately see why that does what it
does, here are some hints:
What does perl -le '($a = "aabbb") =~ s/b+$/c/g; print $a' do?
What would s/b*$/c/g do if there aren't any "b"s at the end of the matched string?
How many "b"s are matched to produce the first "c"? How many "b"s are matched
produce the second "c"?
More information about the london.pm