Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: problem with optional capture group

by GrandFather (Saint)
on Dec 22, 2020 at 20:05 UTC ( [id://11125634]=note: print w/replies, xml ) Need Help??


in reply to problem with optional capture group

As a general thing any .[*+] match is suspect. An often useful trick is to use a negative lookahead match to nibble one character at a time:

my $str = "Send it to bob.sled\@gmail.com. Don't send it to ski.guy\@y +ahoo.com."; print "$1\n" if $str =~ /(( (?!\.\s). )+ \.\s)/x;

Prints:

Send it to bob.sled@gmail.com.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-18 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found