Possible Duplicate:
Get individual query parameters from Uri
I have got a URL like this:
http://somedomain.com/website/webpage.aspx?token=123456&language=English
My goal is to extract 123456 from it. There can only be one payment ID in the query-string parameter. What kind of regular expression can I use? I am using C# (.NET) by the way.
Thanks
token=(\d+)should do the trickTo cater for aplhas as well you can do either:
token=([a-zA-Z0-9+/=]+)to explicitly match on the characters you expect. This matches “token=” and then captures all following characters that match the character class, that is, a-z, A-Z, 0-9, +, / and =.or
token=([^&#]+)to match any character except for the ones you know can finish the token. This matches “token=” and then captures all characters until the first&,#or the end of the string.