Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Regex matching a string beginning with "root: " but not containing another string

by ikegami (Patriarch)
on Sep 09, 2004 at 16:22 UTC ( [id://389766]=note: print w/replies, xml ) Need Help??


in reply to Regex matching a string beginning with "root: " but not containing another string

Use a negative lookahead assertion:

@data = split(/\n/, <<'__EOI__'); root: myself@domain.of-my.own anotherone: myself@domain.of-my.own root: yetanother1@domain.of-my.own __EOI__ $email = 'myself@domain.of-my.own'; foreach (@data) { /^root: (?!\Q$email\E)(\S+)/ && print("$1\n"); } __END__ output ====== yetanother1@domain.of-my.own
  • Comment on Re: Regex matching a string beginning with "root: " but not containing another string
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2024-04-19 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found