Comment On RegExp From Down Under

"The company I work for sells vacation packages for Australia," writes Nathan, "and for whatever reason, they're marketed under different two different brands — redacted-travel.com.au and redacted-travel.com — depending on whether you live Down Under or somewhere else in the world." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: RegExp From Down Under

2009-10-05 09:03 • by John (unregistered)
Brillant!

Re: RegExp From Down Under

2009-10-05 09:03 • by Anon (unregistered)
First......

Re: RegExp From Down Under

2009-10-05 09:05 • by John (unregistered)
286887 in reply to 286886
NOT!

Re: RegExp From Down Under

2009-10-05 09:05 • by Jenkins (unregistered)
var comment = new RegExp(/^(W|w)(T|t)(F|f)|(W|w)\.(T|t)\.(F|f)\.$/);

Re: RegExp From Down Under

2009-10-05 09:05 • by Skywalker (unregistered)
You call that a regular expression? This is a regular expression!

Re: RegExp From Down Under

2009-10-05 09:09 • by James (unregistered)
That's not a regex that's a string!

Re: RegExp From Down Under

2009-10-05 09:12 • by Patrick (unregistered)
Looks like someone wanted to use RegEx but didn't know what it's for.

Re: RegExp From Down Under

2009-10-05 09:14 • by Kiss me I'm Polish
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!"

Re: RegExp From Down Under

2009-10-05 09:14 • by Zylon
Well, that's different a different way to do it.

Re: RegExp From Down Under

2009-10-05 09:24 • by JonTurner (unregistered)
Fail. No multithreading.

Re: RegExp From Down Under

2009-10-05 09:28 • by First (unregistered)
RegEx.... Austrailian for String

Re: RegExp From Down Under

2009-10-05 09:28 • by Steve H (unregistered)
Fail for no XML

Re: RegExp From Down Under

2009-10-05 09:29 • by 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.

Re: RegExp From Down Under

2009-10-05 09:29 • by operagost
Forgot to check for "OZ".

Re: RegExp From Down Under

2009-10-05 09:32 • by APaddyInOz (unregistered)
But what about testing for "Orstrylya"?

Re: RegExp From Down Under

2009-10-05 09:32 • by 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.

Re: RegExp From Down Under

2009-10-05 09:32 • by 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)?

Re: RegExp From Down Under

2009-10-05 09:34 • by 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!

Re: RegExp From Down Under

2009-10-05 09:35 • by 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.

Re: RegExp From Down Under

2009-10-05 09:39 • by Ilya Ehrenburg
Since when is New Zealand not outside Australia?
Must be pretty much hated by the Kiwis, that site.

Re: RegExp From Down Under

2009-10-05 09:39 • by Not JWZ (unregistered)
"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."

Re: RegExp From Down Under

2009-10-05 09:41 • by Lee K-T (unregistered)
And what if the bloke enters "shenanigans"?

Re: RegExp From Down Under

2009-10-05 09:44 • by Kiss me I'm Polish
286908 in reply to 286906
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.

Re: RegExp From Down Under

2009-10-05 09:47 • by Steerpike (unregistered)
That regex should go straight to the poolroom.

Obviously the developer is an ideas man.

(Tell him he's dreaming).

http://www.youtube.com/watch?v=TM-GVRvsZrA

Re: RegExp From Down Under

2009-10-05 09:47 • by NightDweller
286910 in reply to 286901
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.




Re: RegExp From Down Under

2009-10-05 09:50 • by 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.

Re: RegExp From Down Under

2009-10-05 09:51 • by Anon (unregistered)
286912 in reply to 286901
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".

Re: RegExp From Down Under

2009-10-05 09:56 • by 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!

Re: RegExp From Down Under

2009-10-05 09:56 • by Anon (unregistered)
286914 in reply to 286911
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.

Re: RegExp From Down Under

2009-10-05 10:02 • by @Deprecated (unregistered)
286916 in reply to 286914
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

Re: RegExp From Down Under

2009-10-05 10:18 • by Edward Royce (unregistered)
286918 in reply to 286897
Steve H:
Fail for no XML


Hmmmm.

It needs XPath!

Re: RegExp From Down Under

2009-10-05 10:24 • by Beaker (unregistered)
286919 in reply to 286916
@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.

captcha is "plaga": Spanish for plague.

Re: RegExp From Down Under

2009-10-05 10:26 • by Markp
286920 in reply to 286898
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?

Re: RegExp From Down Under

2009-10-05 10:31 • by Markp
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)$/);

Re: RegExp From Down Under

2009-10-05 10:33 • by Rowan Lewis (unregistered)
TRWTF is all the people using pseudo Australian slang.

Re: RegExp From Down Under

2009-10-05 10:39 • by Vechni
i dont even know

Re: RegExp From Down Under

2009-10-05 10:40 • by !? (unregistered)
286925 in reply to 286903
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.

Re: RegExp From Down Under

2009-10-05 10:41 • by PeriSoft
They should have just reported their international site to Australia's government censorship board, and let the ISPs do the work.

Re: RegExp From Down Under

2009-10-05 10:42 • by Badger (unregistered)
...what I want to say?

Re: RegExp From Down Under

2009-10-05 10:44 • by danixdefcon5
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"!!!

Re: RegExp From Down Under

2009-10-05 10:45 • by Bim Job (unregistered)
286929 in reply to 286908
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?

Re: RegExp From Down Under

2009-10-05 11:00 • by @Deprecated (unregistered)
286930 in reply to 286919
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.

captcha is "plaga": Spanish for plague.


Sorry, I thought we were offering up ridiculous ideas here today.

Re: RegExp From Down Under

2009-10-05 11:06 • by !? (unregistered)
286932 in reply to 286916
@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.

Re: RegExp From Down Under

2009-10-05 11:14 • by no one (unregistered)
Why do a stach of ifs?

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

Re: RegExp From Down Under

2009-10-05 11:14 • by Anon (unregistered)
286934 in reply to 286919
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.

Re: RegExp From Down Under

2009-10-05 11:16 • by Anon (unregistered)
286935 in reply to 286933
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>

Re: RegExp From Down Under

2009-10-05 11:16 • by danixdefcon5
286936 in reply to 286932
!?:
@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...

Re: RegExp From Down Under

2009-10-05 11:19 • by Kharkov (unregistered)
Alternate solution:
ask the Powers Below to add the site to the Great Australian Firewall list of blocked sites...

Re: RegExp From Down Under

2009-10-05 11:19 • by Markp
286938 in reply to 286905
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).

Re: RegExp From Down Under

2009-10-05 11:20 • by Alan (unregistered)
286939 in reply to 286898
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.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment