带标签的字符串怎么截取
string aa="dddg[Fsx.List:ghgfhgfhgffjtttt]111[/Fsx.List]不是标签中的字符[Fsx.List:ghgfhgfhg]222[/Fsx.List]"
请问怎么用以下方法实现:把aa中所有的[Fsx.List:...][/Fsx.List]给删除。关键是找不出所有[Fsx.List:...][/Fsx.List],如果找出来用replace替换掉就行了。
foreach (Match m in Regex.Matches(aa, @"(?is)\[Fsx\.List.*?\](.*?)\[/Fsx\.List\]"))
{
}
[解决办法]
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*/