Dim r As New Regex("[&?]userID=[^\s&#]+", RegexOptions.IgnoreCase)
Dim strUrl As String = r.Replace(app.Context.Request.Url.ToString, "")
strUrl = strUrl.Replace("aspx&", "aspx?")
Response.Redirect(strUrl)
For my notes:
[&?] Match one of the items in the list
userID= Match the literal string
[^\s&#]+ the caret(^) inside the brackets ([]) means to match anything NOT in the list
\s is a space
Match a single character NOT present in the list below «[^\s&#]+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
A whitespace character (spaces, tabs, and line breaks) «\s»
One of the characters “&#” «&#»
Created with RegexBuddy