Vote count:
0
I am trying to use regex to match a query string pattern and am having some issues. The URL is "http:http://ift.tt/1lpH36s". This page can have a variety of query string vaiables and values attached in a non-specific order. What i want to do is get the value of one of these variables and use it. Thus, for all of these examples:
http:\\http://ift.tt/1fp3KQX
http:\\http://ift.tt/1fp3L7b
http:\\http://ift.tt/1lpH4r6
http:\\http://ift.tt/1lpH4r8
http:\\http://ift.tt/1lpH4r6
http:\\http://ift.tt/1fp3Nfm
I want to extract the value "name" from the city variable and use it. What I've come up thus far is:
/dir\/page.aspx\?(.*&)?city=(.*)(?=&.*)/
and using $2 for that value.
This works ok for some cases but doesnt seem to catch them all. I believe my issue is here:
city=(.*)
and that I need to stop capturing at the first appearance of an ampersand, but my random copy and paste efforts have not been successful. Can anyone explain how I would catch any and all characters until a particular one appears?
Aucun commentaire:
Enregistrer un commentaire