Expand my Community achievements bar.

Can i use /^USA$/ for a exact match? is it safe? any better idea?

Avatar

Level 8

Hello

I have  my_string of my_text_field (but its hidden), for example, FRANCE USA_ILANDS GERMANY (space between these each country / words.....actually, all these country names are NAMES of text fields/drop-downs/check boxes on my_form) like that i am concatenating around 200 countrries, well.

Now, i want to search for a match in my_string, say for example, am looking to search for a match of USA, so i put the below JS,


I am expecting the return value should be false.

But, its coming as true!

From Google,

http://stackoverflow.com/questions/447250/matching-exact-string-with-j avascript

Am following the first suggested option with place holders like, var r = /^a$/ its working fone for me

Pls. let me know is this is safe? ok? recommendabale? or Any other help to find out exact match word?

Thank you

1 Reply