in reply to Counting characters within regexp
G'day Bod,
This looked a short, fun exercise. I threw this together before looking at any reponses.
$ perl -Mstrict -Mwarnings -E ' my @email = ( q{someone@example.co.uk}, q{andrew.test@some.company.co.uk}, q{jo@abc.com}, ); for my $email (@email) { my ($nm0, $nm1, $at, $ad0, $ad1, $tld) = $email =~ /^(..)([^@]*)(@)(..)(.*?)(\.[^.]+)$/; say $email; say $nm0, "."x length($nm1), $at, $ad0, "."x length($ad1), $tl +d; } ' someone@example.co.uk so.....@ex.........uk andrew.test@some.company.co.uk an.........@so..............uk jo@abc.com jo@ab..com
There are some similarities to what others have posted.
— Ken
|
|---|