正規表現を使用して、指定されたテキストの既存の URL を新しい URL に置き換えようとしています。私が使用している正規表現パターンに一致するものがないようです:
string regex = "<a href=\"http://domain/page.asp?id=(\\d+)&oid=(\\d+)&type=(\\w+)\">";
誰かが次のような URL を見つけるための正しいパターンを書くのを手伝ってくれませんか?
"<A href=\"http://domain/page.asp?id=38957&oid=2497&type=JPG\">"
以下は、使用しているパターンに一致するものが見つからないテスト コードです。
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)\">");