日期:2014-05-18 浏览次数:21139 次
string aa="dddg[Fsx.List:ghgfhgfhgffjtttt]111[/Fsx.List]不是标签中的字符[Fsx.List:ghgfhgfhg]222[/Fsx.List]"; Regex reg = new Regex(@"(\[Fsx\.List:.+?\])(.+?)(\[/Fsx\.List\])"); string result = reg.Replace(aa, "$2"); /* dddg111不是标签中的字符222 */
------解决方案--------------------
string str= @"[Fsx.List:TabelName=admin,IsPage=true,ShowPageNum=true]
说明:(里面属性个数不确定)
内容...
[/Fsx.List]
[Fsx.List:TabelName=admin,IsPage=true,ShowPageNum=true]
说明:(里面属性个数不确定)
fdasf
内容...
fdasf
[/Fsx.List]";
string pattern=@"(?is)(\[Fsx\.List:[^[]*?\])(.*?)(\[/Fsx\.List\])";
str = Regex.Replace(str, pattern,"$2");
/*
fasdfasfasf
说明:(里面属性个数不确定)
内容...
gdsgfdsgfsd
说明:(里面属性个数不确定)
fdasf
内容...
fdasf
*/