• MeBerserk (unregistered)

    i remember that site!!!! I didn't know what to do so just added a space or a dot and it worked =D yay =p

  • (cs)

    TRWTF is nobody had yet suggested a server side IP/Country validation and redirection.

    But TRRWTF is the persistent error message in TDWFT still labeled "Worse than failure".

  • (cs) in reply to Skywalker
    Skywalker:
    You call that a regular expression? This is a regular expression!

    Hey, man, that's just a spoon.

  • RBoy (unregistered) in reply to Anon
    Anon:
    First......

    You sadden me. If you are going to First, you need to either use the code from the article to first, or to Fist.

    All I'm asking is that you follow the unwritten conventio that we all didn't agree on (as it's unwritten).

  • SCB (unregistered)

    The simplest thing to do would be to ask the user to enter their distance in miles (or kilometers) from Australia, and then test it for zero.

  • (cs)

    Ah, I see the WTFs... the missing space after "country,", and the double space after "if".

  • (cs) in reply to Anon
    Anon:
    Beaker:
    @Deprecated:
    Anon:
    halcyon1234:
    Why use a regex? It's so inefficient for finding what's effectively a known quantity. They're not searching for any string, they're searching for a particular one. Sure, there's some permutations with capitalization, but those can be checked for with some hard coded values. As long as you put them in the right order, they index search will be faster than the initialization of the regex engine.

    if (inputbox.value == "australia") alert ("You cannot be in australia"); else if (inputbox.value == "australiA") alert ("You cannot be in australiA"); else if (inputbox.value == "australIa") alert ("You cannot be in australIa"); else if (inputbox.value == "australIA") alert ("You cannot be in australIA"); else if (inputbox.value == "austraLia") alert ("You cannot be in austraLiA");

    etc. Nothing a bit of copy'n'paste (or Excel manipulating) can't produce in less time than mucking with a regex could.

    Sounds legit.

    He's going about this all wrong. Instead, the code should test for every other country in the world, and let those pass. That way you can't submit with Austarlia or NewZaeland

    Good idea, but the array of strings that could be other countries might be a bit too big to test in a for-switch.

    Simple, we put them in a database and then get retrieve them as XML via a web service and use that to dynamically generate a giant if/else if construct to check for countries that are allowed to pass. If more countries are created later, you can simply update the database and everything is taken care of.

    Or they could use a neural network!

  • MikeCD (unregistered) in reply to RHuckster
    RHuckster:
    Hey, man, that's just a spoon.
    I see you've played Stringy-Spoony before!
  • Jay (unregistered) in reply to Ilya Ehrenburg
    Ilya Ehrenburg:
    Since when is New Zealand not outside Australia? Must be pretty much hated by the Kiwis, that site.

    Ah, apparently you haven't heard about the coup.

  • monkeyPushButton (unregistered)

    There are too many variations in country names to make the array feasible. As well, there are too many possible ways around the regex. What is needed is a foolproof way to determine if the user is in Australia. All that is needed is a simple radio button.

    "When you greet someone you say: O - "Hello" O - "G'Day mate""

    Nice and simple.

  • Mike (unregistered) in reply to Kalem13

    No they don't. If they live in Australia and are booking on redacted-travel.com it tells them to go to redacted-travel.com.au.

    Dumbest...regex...EVER.

  • (cs)

    Wouldn't you also need to match "puɐ1ɐǝz ʍǝu" or "ɐı1ɐɹʇsnɐ"?

  • spike (unregistered)
    Gieron:
    When faced with a problem a lot of people think "I'll use a regexp", now they have two problems.

    No, I don't know what it means either.

    I'm not sure either, but this is the best explanation i could think of.

    By applying regular expressions as a universal solution, all you have done is moved your problem into a new domain, so you have your original problem, and the new problem of writing a regular expression. As far as i can tell, its yet another warning against the golden hammer approach.

    The statement also humorously implies that regular expressions don't solve anything.

    well that's the best i can do. I'm sure if I'm incorrect someone will tell me about it.

  • Anon (unregistered) in reply to TheCycoONE
    TheCycoONE:
    Anon:
    Beaker:
    @Deprecated:
    Anon:
    halcyon1234:
    Why use a regex? It's so inefficient for finding what's effectively a known quantity. They're not searching for any string, they're searching for a particular one. Sure, there's some permutations with capitalization, but those can be checked for with some hard coded values. As long as you put them in the right order, they index search will be faster than the initialization of the regex engine.

    if (inputbox.value == "australia") alert ("You cannot be in australia"); else if (inputbox.value == "australiA") alert ("You cannot be in australiA"); else if (inputbox.value == "australIa") alert ("You cannot be in australIa"); else if (inputbox.value == "australIA") alert ("You cannot be in australIA"); else if (inputbox.value == "austraLia") alert ("You cannot be in austraLiA");

    etc. Nothing a bit of copy'n'paste (or Excel manipulating) can't produce in less time than mucking with a regex could.

    Sounds legit.

    He's going about this all wrong. Instead, the code should test for every other country in the world, and let those pass. That way you can't submit with Austarlia or NewZaeland

    Good idea, but the array of strings that could be other countries might be a bit too big to test in a for-switch.

    Simple, we put them in a database and then get retrieve them as XML via a web service and use that to dynamically generate a giant if/else if construct to check for countries that are allowed to pass. If more countries are created later, you can simply update the database and everything is taken care of.

    Or they could use a neural network!

    Yes, but it'll have to run on a cloud network.

  • (cs)

    The biggest WTF is that I could immediately see the WTF, even though RegExp is a subject that I find confusing and hard to understand.

  • MicDundee (unregistered)

    I confused, I thought Austria's internet country code was .AT

  • Some Dreamer (unregistered) in reply to Anon
    Anon:
    TheCycoONE:
    Or they could use a neural network!

    Yes, but it'll have to run on a cloud network.

    You've always got your head in the clouds...

  • AP (unregistered)

    Also the anchors are probably wrong (although they do not affect the outcome). You are going to check for something that beings with A or a OR <options in the middle> or Something that ends with D. The ^ and $ are just wrong.

  • Jeremy (unregistered) in reply to Lee K-T
    Lee K-T:
    And what if the bloke enters "shenanigans"?

    Since the code does not have a shenanigans handler, it would not work properly!

  • O'hagan (unregistered)

    I swear to God I'm going to pistol whip the next guy who says, Shenanigans.

  • Steve (unregistered)

    TRWTF is that the regexp is just plain wrong.

    Rather than matching at "random": /^australia|newzealand|new zealand$/i

    it'd be wiser to check for the beginning and the end: /^(?:australia|new ?zealand)$/i

    Unless I'm completely mistaken of course...

  • Mac (unregistered) in reply to O'hagan
    O'hagan:
    I swear to God I'm going to pistol whip the next guy who says, Shenanigans.

    Hey Farva what's the name of that restaurant you like with all the goofy shit on the walls and the mozzarella sticks?

  • Scott (unregistered)
    they're marketed under different two different brands

    You repeated accidentally repeated yourself.

  • (cs)

    Time to whip out a Drop-Down-Under Box.

  • iMalc (unregistered)

    Being a New Zealander myself I hate those friggin Aussie site versions. The international sites insist that you must use the Aussie one, and the Aussie one insists that you must live in Aussie. At least that's my experience.

    You know there is one tiny advantage to the regexp presented, if you wanted to catch New Zea1and (a one in place of the L) then it's a pretty simple modification. And then there's N3w Z3a1and etc...

    Still I'd think converting to uppercase and then using the Levenshtein distance would be a better way to catch it.

  • Brandon (unregistered)

    While fun to insult people on regular expressions, I really feel that it is one of two criteria to being a successful programmer. Those two being...

    1. Ability to write regular expressions for common and complex pattern matching and
    2. Ability to write efficient recursive algorithms.

    Those two items, more than any thing else, have, in my experience, shown who knows programming, and who just has a piece of paper from some school.

  • Jishnu (unregistered)

    You just have to enter @U$TR@L!@ :P

  • JohnB (unregistered)

    I'm guessing Santa didn't use them.

  • (cs) in reply to Yazeran
    Yazeran:
    Besides, how many ways are there to spell Australia using 'funny' characters as substitutes to fool this check (or just plain spelling errors)????

    Or, since JavaScript is normally disabled by default, just submit normally.

  • Paul Hogan (unregistered) in reply to iMalc
    iMalc:
    ... insists that you must live in Aussie...

    grr - why do Kiwis insist on calling Australia 'Aussie'. No-one lives in Aussie, you live in 'Australia', 'straya' or 'Oz' or 'Gods country'. :-p An Australian person is an Aussie.

    It can't be both the country and the person. eg - you are a Kiwi - you don't live in Kiwi. [/ThusEndethTheLessonAmenBro]

  • Mason Wheeler (unregistered) in reply to Scott
    Scott:
    they're marketed under different two different brands

    You repeated accidentally repeated yourself.

    You oughtta report them to the Department of Redundancy Department.

  • Daniel (unregistered) in reply to ais523
    ais523:
    There are at least 2 WTFs here. First, that what they've written could have been written a lot more succinctly (the regex should be marked case-insensitive, and even for a developer unaware of that option it could be written much more simply than that....). Second, what the code actually does is probably a bad idea in the first place. (A drop-down box for the country might work better than trying to parse entered country names, with either a prompt disallowing Australia and New Zealand, or just not putting them there in the first place; but even then, what they're trying to accomplish is probably not a good idea, especially as a drop-down box has usability problems of its own.) Other potential WTFs here (as in, almost certainly a WTF, but there isn't enough information in the article to tell): if that validation code isn't duplicated server-side, or if the server-side validation code has the same, or a different, bug; and is there a good reason to not just process the info as if it had been entered in the other website (or auto-redirect to the other website, or just not have two websites at all)?

    You, my good Sir, is clearly The-Real-WTF.

  • (cs) in reply to iMalc
    iMalc:
    Being a New Zealander myself I hate those friggin Aussie site versions. The international sites insist that you must use the Aussie one, and the Aussie one insists that you must live in Aussie. At least that's my experience.

    Isn't it possible for the site itself to know where the site visitor is accessing the site from? There are sites I visit that somehow know that I'm accessing it from Honolulu and automatically provide some kind of "localization", such as saying "Aloha" on the welcome screen. So, couldn't these Australian/New Zealand sites know whether the visitor is accessing the site from within either of those countries and automatically redirect the user to the appropriate site?

  • Dingo Chamberlain (unregistered) in reply to danixdefcon5
    danixdefcon5:
    !?:
    @Deprecated:
    Anon:
    halcyon1234:
    Why use a regex? It's so inefficient for finding what's effectively a known quantity. They're not searching for any string, they're searching for a particular one. Sure, there's some permutations with capitalization, but those can be checked for with some hard coded values. As long as you put them in the right order, they index search will be faster than the initialization of the regex engine.

    if (inputbox.value == "australia") alert ("You cannot be in australia"); else if (inputbox.value == "australiA") alert ("You cannot be in australiA"); else if (inputbox.value == "australIa") alert ("You cannot be in australIa"); else if (inputbox.value == "australIA") alert ("You cannot be in australIA"); else if (inputbox.value == "austraLia") alert ("You cannot be in austraLiA");

    etc. Nothing a bit of copy'n'paste (or Excel manipulating) can't produce in less time than mucking with a regex could.

    Sounds legit.

    He's going about this all wrong. Instead, the code should test for every other country in the world, and let those pass. That way you can't submit with Austarlia or NewZaeland

    And it might be necessary to check for all the misspellings the country names may have in english and every other language, including esperanto.

    I think "Australia" has the same name/spelling in most languages. "Nueva Zelanda" does break that regexp though.

    Allowing textfields for country could bring on interesting results... wonder if someone would put "Sealand" or "Lizbekistan" there...

    'Australia' is spelt different in many different countries... I've seen Europeans spell it 'Austria' and (as anyone who watches John Clarke [About the only good thing to ever come out of NZ] would know) the Australians spell it 'Straya'

  • Johnno (unregistered) in reply to iMalc
    iMalc:
    Being a New Zealander myself I hate those friggin Aussie site versions. The international sites insist that you must use the Aussie one, and the Aussie one insists that you must live in Aussie. At least that's my experience.

    You know there is one tiny advantage to the regexp presented, if you wanted to catch New Zea1and (a one in place of the L) then it's a pretty simple modification. And then there's N3w Z3a1and etc...

    Still I'd think converting to uppercase and then using the Levenshtein distance would be a better way to catch it.

    Looks like the plan is working...

    Apparently the Australian versions of many sites didn't realise that sheep surf the net too...

  • Patrick (unregistered) in reply to Kalem13

    Um, no, the two sites are different. It refers them to the .au version of the site if they live in Australia.

  • Bad William (unregistered) in reply to bored
    bored:
    captcha: vulputate - A masturbating vulture?
    Heh heh. Heh heh heh. He said "vulputate".
  • TJ (unregistered) in reply to Dingo Chamberlain

    You know.. Europeans spelling Austria is probably referring to the country Austria.

  • (cs)

    In countries like Australia. Such as New Zealand. And Australia itself.

  • anonymous (unregistered) in reply to Kalem13
    Kalem13:
    I like how they tell customer to visit the exact same site if they enter australia as a country. A clueless user could enter some kind of infinite loop and try to book forever.

    A clueless user don't even need one website to enter a infinite loop.

  • Garmoran (unregistered) in reply to Ilya Ehrenburg
    Ilya Ehrenburg:
    Since when is New Zealand not outside Australia? Must be pretty much hated by the Kiwis, that site.
    Yeah, in the same way that I want to find a webmaster and ram a rolled up map down his/her throat each time I find a site that infers that the Highlands of Scotland are separated by an invisible stretch of water from the region commonly referred to as "Mainland UK".
  • giofj (unregistered)

    TRWTF is using \b[reg(ular expressions?|ex(p|es)?)]\b!

  • Garmoran (unregistered) in reply to SCB
    SCB:
    The simplest thing to do would be to ask the user to enter their distance in miles (or kilometers) from Australia, and then test it for zero.
    Gets my vote!
  • swordfishBob (unregistered) in reply to Ilya Ehrenburg
    Ilya Ehrenburg:
    Since when is New Zealand not outside Australia? Must be pretty much hated by the Kiwis, that site.
    Yeah, the Real WTF(tm) is what the Kiwis will say when they discover they're now Australia's Florida (call it "Shebangabang").
  • bec (unregistered) in reply to MicDundee

    no, it's .there_are_no_kangaroos

  • bec (unregistered) in reply to bec
    MicDundee:
    I confused, I thought Austria's internet country code was .AT

    sorry, the last comment was supposed to quote this. now I just feel stupid.

  • Zippy (unregistered)

    OMG! I haven't laughed that hard in weeks!

    Thanks!

  • (cs) in reply to Paul Hogan
    Paul Hogan:
    iMalc:
    ... insists that you must live in Aussie...

    grr - why do Kiwis insist on calling Australia 'Aussie'.

    ROFL 'cos it keeps on getting a rise out of you, like duh?
  • (cs) in reply to Anon
    Anon:
    Gieron:
    When faced with a problem a lot of people think "I'll use a regexp", now they have two problems.

    No, I don't know what it means either.

    Not JWZ:
    "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."

    Thanks for clarifying that, "Not JWZ".

    Reading comprehension fail combined with LERN2INTERNETZ. See those quote marks that "Not JWZ" used? They're not just meaningless decoration. "Not JWZ" clarified it perfectly well for you, because if you google the original wording the only result you get is this TDWTF thread, but if you google the exact original quote that "Not JWZ" gave you, you get all sorts of useful stuff about what it means and where it comes from.
  • Lobe (unregistered) in reply to Ilya Ehrenburg
    Ilya Ehrenburg:
    Since when is New Zealand not outside Australia? Must be pretty much hated by the Kiwis, that site.
    You don't want to put Australians and New Zealanders together. They have a "friendly rivalry". Which means they act like the people who leave comments on Youtube.

    Captcha: eros. That's just pandering to the audience that is.

Leave a comment on “RegExp From Down Under”

Log In or post as a guest

Replying to comment #:

« Return to Article