J
John Doe
Hi,
I'm having some trouble with the regexp :/
I'm messing up with the match, scan methods, I'm not sure wich one I
should use.
Here's what I'm trying to do :
I have a string that's an URL with get values :
Ex :
foo.bar/somePath/somepage.php?attr=value&theone=64646hs554&other=ddd
What I need is the value of the "theone" attribute.
This attribute may or may not be the last one in the string !
I don't know if it's possible to put the two cases in one regexp...
Here are my two regexp :
If it's not the last attribute
/session=(.*?)&/
If it's the last attribute
/session=(.*?)$/
What should I use next to extract the value ? scan or match ?
myString.scan(/session=(.*?)&/) ?
How can I handle the two situation ?
Thanks a lot for your help !
(Sorry for my english)
Pollop.
I'm having some trouble with the regexp :/
I'm messing up with the match, scan methods, I'm not sure wich one I
should use.
Here's what I'm trying to do :
I have a string that's an URL with get values :
Ex :
foo.bar/somePath/somepage.php?attr=value&theone=64646hs554&other=ddd
What I need is the value of the "theone" attribute.
This attribute may or may not be the last one in the string !
I don't know if it's possible to put the two cases in one regexp...
Here are my two regexp :
If it's not the last attribute
/session=(.*?)&/
If it's the last attribute
/session=(.*?)$/
What should I use next to extract the value ? scan or match ?
myString.scan(/session=(.*?)&/) ?
How can I handle the two situation ?
Thanks a lot for your help !
(Sorry for my english)
Pollop.