// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Specialized; using System.Web; namespace E { public class Program { public static void Test1(string s) { Console.WriteLine(s + " --> " + HttpUtility.ParseQueryString(s)["q"]); } public static void Test2(string s) { Console.WriteLine(s + " --> " + HttpUtility.ParseQueryString((new Uri(s)).Query)["q"]); } public static void Main(string[] args) { Test1("?hl=da&q=test&meta="); Test1("?q=test&Form=MSNH&cp=65001"); Test1("http://www.google.dk/search?hl=da&q=test&meta="); Test1("http://search.msn.dk/results.aspx?q=test&Form=MSNH&cp=65001"); Test2("http://www.google.dk/search?hl=da&q=test&meta="); Test2("http://search.msn.dk/results.aspx?q=test&Form=MSNH&cp=65001"); } } }