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

Re: real world extended regex examples

by Eimi Metamorphoumai (Deacon)
on Oct 12, 2006 at 15:44 UTC ( #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 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?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2020-10-30 20:15 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (284 votes). Check out past polls.