正则表达式要匹配双引号"如何才能匹配
正则表达式要匹配双引号"怎么匹配?
比如:<A href="index.htm">
要替换成<A href="search.aspx?url=index.htm">
或者:<A href="1280.htm">
要替换成<A href="search.aspx?url=1280.htm">
string test ="<A href="1280.htm">";
test = Regex.Replace(test, @"<a\s*href= (/ .htm}", "search.aspx?" + "$1", RegexOptions.IgnoreCase);
MessageBox.Show(test);
不知道IC交易网该如何去构造这个正则表达式了
---
要匹配IC交易网引号就直接去匹配引号不就行了么,不明白楼主所说意思
- C# code
-
string source = "<A href=\"index.htm\">"; string resutl = Regex.Replace(source, "(?<=<A\\s*href=\").*?\\.htm(?=\">)", "search.aspx?url=$0"); Console.WriteLine(resutl);
- 比如: <A href="index.htm">
要替换成 <A href="search.aspx?url=index.htm">
或者: <A href="1280.htm">
要替换成 <A href="search.aspx?url=1280.htm">
转义下就可以拉 \"
string str = "<A href=\"1280.htm\">";
str = str.Replace("href=\"", "href=\"search.aspx?url=");
Console.WriteLine(str);
Console.ReadKey();