Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: real world extended regex examples

by Eimi Metamorphoumai (Deacon)
on Oct 12, 2006 at 15:44 UTC ( [id://577883]=note: print w/replies, xml ) Need Help??


in reply to real world extended regex examples

You might look at the rules in SpamAssassin, and the custom rules at, say http://www.rulesemporium.com/. Lots of complex patterns, particuarly the (?:posi|nega)tive look-(?:ahea|behin)d.

As a simple example, consider something like /\bviagra\b/i. Now assume you want to match also "\/i@gr@" (very simple obfuscation). If you do /\b(?:\\\/|v)i[@a]gr[@a]\b/i, it doesn't actually work for what you want it to. That's because \b insists on a word boundery, and since \ and @ aren't word characters, they'll only match if adjacent to non-word characters. So what you really want is /(?<!\w)(?:\\\/|v)i[@a]gr[@a](?!\w)/i.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-24 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found