Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Regex question: filtering a bunch of complete words

Discussion in 'General Discussion' started by silverbytes, Jun 1, 2006.

  1. silverbytes

    silverbytes Member

    Joined:
    May 31, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    151
    I have many filters using body match regex using \\\\bspamword\\\\b the issue is that I won't create 1 filter for each word but I ignore the right syntax in regular expressions to put something like:


    Find the complete word spamword OR the complete word spamword2 OR spamword3

    I guess is very simple to combine all my filters into one

    Notice that I should enter \\\\b instead \b in order to work... don't ask me why, just another user gave out the trick.

    So can you help us all with this? is OR a symbol like ^ ?
     
  2. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    166
    Regular expressions use the pipe character to represent boolean OR.

    The pipe character is: |

    For me with my UK keyboard, that's the key to the left of 'z' whilst pressing the shift key.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. silverbytes

    silverbytes Member

    Joined:
    May 31, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    151
    So assuming I need to filter mortage and mortgage this should work:

    \\\\bmortage\\\\b|\\\\bmortgage\\\\b

    Ok let's go beyond: how do I filter variations of same word? Let's focus on sex, sex?, sexy, sexy!

    Is there a starting character and a wildcard I can use covering certain amount of characters?

    IE you want to filter sex, sexy, sexy? but no sextos (the last word is spanish but not related to sex)


    (starting character)sex(anyother 1character or 2 characters)

    Can you recommend a place to learn the syntax?
     
  4. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    166
    Search Google . . .
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice