日期:2014-05-17 浏览次数:21006 次
protected void Page_Load(object sender, EventArgs e)
{
string cs = "abccccccdddddbbeeeaaadddd";
string titlereplace = "a||b";
//我想要的结果就是,把CS中的a,替换成b的正则,求助!
Response.Write(cs);
}
public string abc(string html,string cs)
{
string regularexpression = @"这里不知道该怎么写";
Regex regex = new Regex(regularexpression);
html = regex.Replace(html, cs);
return html;
}
string source = "abccccccdddddbbeeeaaadddd";
Regex reg = new Regex(@"(?is)a");
source = reg.Replace(source, @"b");
MessageBox.Show(source);
string cs = "abccccccdddddbbeeeaaadddd";
string titlereplace = "a
------解决方案--------------------
b<br>c
------解决方案--------------------
d";
var list = Regex.Matches(titlereplace, @"(?<=^
------解决方案--------------------
>)([^\
------解决方案--------------------
]+?)\
------解决方案--------------------
\
------解决方案--------------------
([^\
------解决方案--------------------
<>]+)(?=<
------解决方案--------------------
$)").Cast<Match>().Select(a => new {
pre=a.Groups[1].Value,
next=a.Groups[2].Value
});
foreach (var item in list)
{
cs = Regex.Replace(cs,item.pre,item.next);