• Nanis (unregistered)

    I don't see the frist problem ;-)

  • Erik (unregistered)

    [^:<>|@] matches "asdf:<>|@"; the first match is "a". Where you thinking about ^[^:<>|@]$?

  • I dunno LOL ¯\(°_o)/¯ (unregistered) in reply to Erik

    He probably meant ^[^:<>|@]*$

    Also, fun how putting it in a sentence with punctuation changes the meaning of the regex.

  • I'm not a robot (unregistered) in reply to I dunno LOL ¯\(°_o)/¯

    Given how hard people evidently find it to write the negation of even a simple regex, maybe this code isn't such a WTF after all.

  • my name is missing (unregistered)

    Is a negative regex an irregex or an aregex?

  • MacFrog (unregistered) in reply to my name is missing

    How about negregex?

  • Undefined ERROR {MESSAGE} Please contact dev! This should not happen... (unregistered)


  • Mike (unregistered) in reply to my name is missing

    I'd suggest negex

  • isthisunique (unregistered)

    The worst thing like this I've seen is people making classes such as "ProperRegex" or "AwesomeBestlyPracticingRegex" that extend regex and override methods to throw exceptions when there's a none match. You then see oodles of what should be if statements replaced with exception handling.

  • RichP (unregistered) in reply to my name is missing


  • healing (unregistered)

    never knew the joke until now !!!

    People kept it from me. They would come up to me. A socially induced aphasia due to conflict, later self-healed.

    Tumors effectively receive the spectrum. I had no clue what that meant. I had no clue of the name until now. That's all!

    I read Hawking thoroughly, really tried to understand what he was getting at. The Fluid Mechanic theories, much more cooler!!!

    They say they need a delivery system. There it is. Just ping the hubble. Aliens want us to tune it out.

    They tried to mensa my father with me forever. I think it was due to draft dodging?

    He had one answer when they did it to him.

    MY genes!

    ME !!!

    <what> hitler ???

    just borneo the bastard!

  • cowboys (unregistered)

    it's cool!!! my genes !!! God Save the Queen!

  • RegexNotEvenOnce (unregistered)

    Don't you need to escape some of those characters? e.g. backslash and pipe?

  • cowboys (unregistered)



  • cowboys (unregistered)


  • Smash (unregistered) in reply to MacFrog

    Maybe unregex? What about notregrex? Or xeger?

  • Murray (unregistered)

    In many cases you can't use a regex to specifically not match another regex. Or, you want to allow anything that matches regex A but not regex B, in which case making 2 regexes (regices?) is legit.

    The inheritance is a WTF indeed though.

  • urkerab (nodebb) in reply to Murray

    You can if your regex library supports negative lookahead, in which case /^(?!.*[:<>|@])/ has a similar effect to /^[^:<>|@]*$/.

  • RLB (unregistered) in reply to isthisunique

    You then see oodles of what should be if statements replaced with exception handling.

    Ah, but you see, that's just it. Once you subscribe to the doctrine of exceptionism, no error at all should ever be handled by an if statement. The only thing if is good enough for is simple things like if (value < 5) ... else if (value > 8) ... else ... . Even if (value != 0) ... is dubious; that should really be handled with a ZeroValueException or something similar.

  • anonymous (unregistered)

    I actually quite like the idea of "inverting" a regular expression by negating the result of the match function. It seems like it could be less error-prone (writing a regular expression to match a specific string or pattern is quite easy but writing a regular expression to not match something is difficult at least once you get past single characters).

  • cowboys (unregistered) in reply to RLB


  • gcewing (nodebb) in reply to my name is missing

    A non-regex! It has shuffled off its mortal parentheses! It has become a Kleene-star in the sky! IT IS AN EX-REGEX!

Leave a comment on “And Now You Have Two Problems”

Log In or post as a guest

Replying to comment #:

« Return to Article