Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Counting characters within regexp

by kcott (Archbishop)
on May 10, 2021 at 06:57 UTC ( [id://11132323]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132323]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found