Re: How to extract variable and its value from URL
- From: "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 11 Jul 2005 15:15:30 -0400
Jozef,
You wouldn't even need a regular expression, you can just parse it apart
on the equals sign and the ampersand (but a regular expression would work
fine as well).
Pass the URL to the constructor of the Uri class, and then use the Query
property to get the query string. Drop the first character (it is always
the question mark), and the rest should be easy to parse. The only thing
you have to worry about at that point is the encoding which is a simple
matter of fixing).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
"Jozef Jarosciak" <joe@xxxxxxxxxxxxx> wrote in message
news:1121107806.318549.139710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>I have url:
> www.site.com/index?a=1&b=2
> www.site.com/index?a=1
>
> and I need a regex or some solution to extract 'a' variable and its
> value.
>
> Any ideas?
> joe
>
.
- References:
- How to extract variable and its value from URL
- From: Jozef Jarosciak
- How to extract variable and its value from URL
- Prev by Date: RE: How to extract variable and its value from URL
- Next by Date: RE: Set the background to a Hex number
- Previous by thread: RE: How to extract variable and its value from URL
- Next by thread: Set the background to a Hex number
- Index(es):
Relevant Pages
|