• John (unregistered)

    Brillant!

  • Anon (unregistered)

    First......

  • John (unregistered) in reply to Anon

    NOT!

  • Jenkins (unregistered)

    var comment = new RegExp(/^(W|w)(T|t)(F|f)|(W|w).(T|t).(F|f).$/);

  • Skywalker (unregistered)

    You call that a regular expression? This is a regular expression!

  • James (unregistered)

    That's not a regex that's a string!

  • Patrick (unregistered)

    Looks like someone wanted to use RegEx but didn't know what it's for.

  • Kiss me I'm Polish (cs)

    But Regular Expressions work so much better! I'm sure the boss said something like "Gidday mate! Why don't you just use a regex to filter out Australians!"

  • Zylon (cs)

    Well, that's different a different way to do it.

  • JonTurner (unregistered)

    Fail. No multithreading.

  • First (unregistered)

    RegEx.... Austrailian for String

  • Steve H (unregistered)

    Fail for no XML

  • Kalem13 (unregistered)

    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.

  • operagost (cs)

    Forgot to check for "OZ".

  • APaddyInOz (unregistered)

    But what about testing for "Orstrylya"?

  • Gieron (cs)
    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.

  • ais523 (cs)

    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)?

  • bored (unregistered)

    Dang no check for a dingo.

    captcha: vulputate - A masturbating vulture?

    trwtf: posting STILL isn't fixed Alex quit writing columns for Dev Disasters and fix this board!

  • Yazeran (unregistered)

    Well I guess they never heard about the /i qualifier.... ;-)

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

    Yours yazeran

    Plabn: To go to Mars one day with a hammer.

  • Ilya Ehrenburg (cs)

    Since when is New Zealand not outside Australia? Must be pretty much hated by the Kiwis, that site.

  • Not JWZ (unregistered)

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

  • Lee K-T (unregistered)

    And what if the bloke enters "shenanigans"?

  • Kiss me I'm Polish (cs) in reply to Not JWZ
    Not JWZ:
    "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."
    There are 10 types of people - those who understand binary, and those who have regular sex.

    Now please can we be done with quoting famous people without giving them proper credit? Pretty please.

  • Steerpike (unregistered)
    Comment held for moderation.
  • NightDweller (cs) in reply to Gieron
    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.

    "Regular expressions are neither"

    I am sure someone will explain this as well.

  • halcyon1234 (cs)

    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.

  • Anon (unregistered) in reply to Gieron
    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".

  • null (unregistered)

    Balderdash! var validator = new RegExp( /^(A|a)(U|u)(S|s)(T|t)(R|r)(A|a)(L|l)(I|i)(A|a) |(N|n)(E|e)(W|w)(Z|z)(E|e)(A|a)(L|l)(A|a)(N|n)(D|d) |(N|n)(E|e)(W|w) (Z|z)(E|e)(A|a)(L|l)(A|a)(N|n)(D|d)$/);

    should be taken out as a global variable in case someone tries to repeatedly make a booking from Australia!

  • Anon (unregistered) in reply to halcyon1234
    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.

  • @Deprecated (unregistered) in reply to Anon
    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

  • Edward Royce (unregistered) in reply to Steve H
    Steve H:
    Fail for no XML

    Hmmmm.

    It needs XPath!

  • Beaker (unregistered) in reply to @Deprecated
    Comment held for moderation.
  • Markp (cs) 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.

    Umm...No? Did you read the article?

  • Markp (cs)

    Ohh, now I get the WTF. They did this:

    var validator = new RegExp(
             /^(A|a)(U|u)(S|s)(T|t)(R|r)(A|a)(L|l)(I|i)(A|a)
              |(N|n)(E|e)(W|w)(Z|z)(E|e)(A|a)(L|l)(A|a)(N|n)(D|d)
              |(N|n)(E|e)(W|w) (Z|z)(E|e)(A|a)(L|l)(A|a)(N|n)(D|d)$/);
    

    When they could've done this:

    var validator = new RegExp(
             /^(A|a)(U|u)(S|s)(T|t)(R|r)(A|a)(L|l)(I|i)(A|a)
              |(N|n)(E|e)(W|w)( )?(Z|z)(E|e)(A|a)(L|l)(A|a)(N|n)(D|d)$/);
    
  • Rowan Lewis (unregistered)

    TRWTF is all the people using pseudo Australian slang.

  • Vechni (cs)

    i dont even know

  • !? (unregistered) in reply to bored
    bored:
    Dang no check for a dingo.

    captcha: vulputate - A masturbating vulture?

    trwtf: posting STILL isn't fixed Alex quit writing columns for Dev Disasters and fix this board!

    Argh! Would you people please stop making bizarre associations between anything latin or latin-like with something sexual.

    If you don't know, search for it. You are on the \b\w*(ing|ed)?\b internet.

  • PeriSoft (cs)

    They should have just reported their international site to Australia's government censorship board, and let the ISPs do the work.

  • Badger (unregistered)

    ...what I want to say?

  • danixdefcon5 (cs)

    This is the reason why devs should be banned from using JavaScript for anything other than field validation, and even then the validation should also be done server-side.

    This regexp doesn't qualify as "validation". Let's see how it gets bypassed by "New Zealand"! :)

    Addendum (2009-10-05 11:11): Meh, this thing ate the extra spaces ... I meant "New[space][space]Zealand"!!!

  • Bim Job (unregistered) in reply to Kiss me I'm Polish
    Kiss me I'm Polish:
    Not JWZ:
    "Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."
    There are 10 types of people - those who understand binary, and those who have regular sex.

    Now please can we be done with quoting famous people without giving them proper credit? Pretty please.

    You're just annoyed because Jamie has a /^(P|p)(O|o)(L|l)(I|i)(S|s)(H|h) |(P|p)(O|o)(L|l)(S|s)(K|k)(I|i)(E|e)$/) surname, aren't you?

  • @Deprecated (unregistered) in reply to Beaker
    Comment held for moderation.
  • !? (unregistered) in reply to @Deprecated
    Comment held for moderation.
  • no one (unregistered)

    Why do a stach of ifs?

    Convert the string to al lowercase, than do a single if.

  • Anon (unregistered) in reply to Beaker
    Comment held for moderation.
  • Anon (unregistered) in reply to no one
    no one:
    Why do a stach of ifs?

    Convert the string to al lowercase, than do a single if.

    <sarcasm>Genius! I can't imagine why nobody else has suggested that yet!</sarcasm>

  • danixdefcon5 (cs) in reply to !?
    !?:
    @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...

  • Kharkov (unregistered)

    Alternate solution: ask the Powers Below to add the site to the Great Australian Firewall list of blocked sites...

  • Markp (cs) 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.

    Meh, depends on if they get better deals that way. Speaking as a Canadian, I can tell you that on a website that provides or sells services or products, 99% of the time I'd rather Canada be included as part of the States. (Hulu, Amazon, and on, and on).

  • Alan (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.

    No? Because the error tells them to visit *.com.au and that is the AU equivalent of *.com or *.us (similar to *.co.uk for commercial websites in the UK).

    Someone made a typo in the actual article, tho, because it's missing the required ".com" in the ".au" domain.

    I hate it when people see a mistake in the article, get all worked up on it and then don't double-check before posting.

Leave a comment on “RegExp From Down Under”

Log In or post as a guest

Replying to comment #:

« Return to Article