Help needed with Regex phrasing.

Discussion in 'Off Topic' started by Werewolf, Aug 21, 2016.

  1. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    779
    Positive Ratings:
    226
    So I am trying to use a regex based word censor to block LMAOBoX users on my TF2 server from being able to spam the chat by blocking out the phrase "LMAOBox". I have SMAC on the server to catch the cheaters, this is just to prevent the chat spam.

    Here's the problem I need help with - I want to allow both "LMAO" and "Box" (as neither of them on their own are offensive) but I can't figure how to block the combined "Lmaobox" without also blocking the seperate "LMAO" and "Box".

    This is what I was using before:
    Code:
    (\W|^)[Ll]{0,1}[Mm]{0,1}[Aa]{0,1}[Oo0]{0,1}[Bb]{0,1}[Oo0]{0,1}[Xx]{0,1}(\W|$)
    And I tried:
    Code:
    (\W|^)[Ll]{0,1}[Mm]{0,1}[Aa]{0,1}[Oo0]{0,1}(\W|$)(\W|^)[Bb]{0,1}[Oo0]{0,1}[Xx]{0,1}(\W|$)
    Neither worked.

    I have been using this page for testing, but as I'm pretty new to using regex I can't figure out how I need to phase it correctly. Is there anyone out there familiar with Regex who could help solve this?
     
  2. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    779
    Positive Ratings:
    226
    Solved thanks to /u/logiasin on Reddit.

    If anyone else want to block 'LMAOBoX' but not the separate 'LMAO' and 'Box' via Regex, use this:
    Code:
    ^.*[Ll][Mm][Aa][Oo0]\W*[Bb][Oo0][Xx].*$
     
  3. Sergis

    aa Sergis L666: ])oo]v[

    Messages:
    1,871
    Positive Ratings:
    1,131
    regex should have some way to be case insensitive and that way even simpler
     
  4. DrLambda

    aa DrLambda L69: Teeheehee, Member

    Messages:
    458
    Positive Ratings:
    454
    You have a problem. You decide to solve it using regex. You now have two problems.
     
  5. Werewolf

    aa Werewolf Probably not a real Werewolf

    Messages:
    779
    Positive Ratings:
    226
    You say that, but SMAC is taking care of the cheaters and the Regex word filter plugin is stopping the spam.

    0 problems now.
     
Tags: