Solved

How can I use Regex to parse the querystring

Posted on 2006-11-15
3
178 Views
Last Modified: 2010-04-16
I know that I can just use Request.QueryString("Page") to get the value "Home"
How can I use Regex to parse the querystring and get the Page Value.

string url = "http://67.59.187.45/events_view.aspx?EventID=322&Page=Home&Bla=Bla"

I want to use regex to parse the url string to get the result:
"Home"
0
Comment
Question by:quest_capital
3 Comments
 
LVL 15

Accepted Solution

by:
ozymandias earned 500 total points
ID: 17954393
string s = "http://67.59.187.45/events_view.aspx?EventID=322&Page=Home&Bla=Bla";
                  Regex r = new Regex("Page=([^&]*)");
                  Match m = r.Match(s);
                  Console.WriteLine(m.Groups[1].Value);
                  Console.ReadLine();
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question