Page 1 of 1

troubles with regex

Posted: Sun Sep 26, 2004 4:22 pm
by newmember
here is query string:
"?sc=aa1&st=001010"
and i'm trying to match
either "?st=001010" or "&st=001010"
with:

Code: Select all

location.search.match("/(&|\?)st=(0|1){6}/");
i tried also:

Code: Select all

location.search.indexOf("/(&|\?)st=(0|1){6}/");
all browsers i'm testing with tell me that something wrong with my regex...
but online regex verifiers say everything is ok...

can anyone please tell me where i'm wrong?
thanks

Posted: Sun Sep 26, 2004 6:22 pm
by feyd
you don't have a regex in Javascript. Regexes of this syntax, do not have quotes around them.

Why are you using Javascript and regexes to find this information? You can just use the QueryString object ([google]Javascript QueryString object[/google]) or better yet, use php to do it.