I'm trying to replace an existing url in given text with a new url using regex. I don't seem to get any matches for the regex pattern I'm using:
string regex = "<a href=\"http://domain/page.asp?id=(\\d+)&oid=(\\d+)&type=(\\w+)\">";
Can someone please assist me write a correct pattern to find urls that look like:
"<A href=\"http://domain/page.asp?id=38957&oid=2497&type=JPG\">"
Below is my test code which cannot find any matches for the pattern I'm using:
string result = string.Empty;
string sampleText = "<A href=\"http://domain/page.asp?id=38957&oid=2497&type=JPG\"><U>Click here for Terms & Conditions...</U></A>";
string regex = "<a href=\"http://domain/page.asp?id=(\\d+)&oid=(\\d+)&type=(\\w+)\">";
Regex regEx = new Regex(regex, RegexOptions.IgnoreCase);
result= regEx.Replace(text, "<a href=\"/newPage/Index/$1&opid=$2)\">");
Uriclass to parse the URLs once you get them using the HAP.