Monday, January 31, 2011

Parsing the Querystring using Regular Expression

public static string GetParamValue(string query,string parameter)
{
string value = string.Empty;
Match match = Regex.Match(query, "[?&]" + parameter + "(?:=([^&]*))?", RegexOptions.IgnoreCase RegexOptions.Singleline);
if (match.Success)
value = match.Groups[1].Value;
return value;
}

No comments:

Post a Comment