代码如下:
string aa = "[Fsx.List:ghgfhgfhgffjtttt]kkk[/Fsx.List]";
Regex reg = new Regex(@"(?is)(?<=\[Fsx\.List:\w+?\]).+?(?=\[/Fsx\.List\])");
Dictionary<string, string> rules = new Dictionary<string, string>();
rules.Add("kkk", "22");
string result = reg.Replace(aa, new MatchEvaluator(m => { return rules.ContainsKey(m.Value) ? rules[m.Value] : m.Value; }));
Response.Write(result);
当变量aa= "[Fsx.List:ghgfhgfhgffjtttt]kkk[/Fsx.List]"时可以把kkk替换成22,但当aa = "[Fsx.List:TabelName=admin,IsPage=true,ShowPageNum=true,PageNumAlign=center,Top=8,PageSize=10,OrderField,Num=0,Order=0]kkk[/Fsx.List]"时就不能替换了,还是输出[Fsx.List:TabelName=admin,IsPage=true,ShowPageNum=true,PageNumAlign=center,Top=8,PageSize=10,OrderField,Num=0,Order=0]kkk[/Fsx.List]
请问怎么回事?谢谢!
string aa = "[Fsx.List:ghgfhgfhgffjtttt]kkk[/Fsx.List]";
Regex reg = new Regex(@"(?is)(?<=\[Fsx\.List:\w+?\]).+?(?=\[/Fsx\.List\])");
Dictionary<string, string> rules = new Dictionary<string, string>();
rules.Add("kkk", "22");
string result = reg.Replace(aa, new MatchEvaluator(m => { return rules.ContainsKey(m.Value) ? rules[m.Value] : m.Value; }));
Response.Write(result);
当变量aa= "[Fsx.List:ghgfhgfhgffjtttt]kkk[/Fsx.List]"时可以把kkk替换成22,但当aa = "[Fsx.List:TabelName=admin,IsPage=true,ShowPageNum=true,PageNumAlign=center,Top=8,PageSize=10,OrderField,Num=0,Order=0]kkk[/Fsx.List]"时就不能替换了,还是输出[Fsx.List:TabelName=admin,IsPage=true,ShowPageNum=true,PageNumAlign=center,Top=8,PageSize=10,OrderField,Num=0,Order=0]kkk[/Fsx.List]
请问怎么回事?谢谢!
解决方案 »
- 很诡异的error: 40报错 - 无法打开到 SQL Server 的连接
- clientid运用的简单问题
- 公司要做一个类似html在线编辑器的网页程序,请教做此程序的方法
- 100分 求解updata问题
- 行列转换!求救!!!!!!!
- 关于一个GridView完成数据绑定和搜索后数据绑定分页的问题
- 为什么我的找不到System.Web.UI.Design空间
- 每5秒在同一窗口播放一张网页(由另一个窗口控制)如何实现?
- 求助:读取datagrid中模板列中textbox值的问题,十分感谢!
- 各位大哥,能不能这样做Me.SqlDataAdapter1.Fill(JjbX),x是一个整型变量?
- 想做一个类似QQ邮箱日历功能的东东~请教!!!
- C#.net中chart控件绑定问题 求大侠们帮忙啊
Regex reg = new Regex(@"(?is)(?<=\[Fsx\.List:[\s\S]+?\]).+?(?=\[/Fsx\.List\])");
\w只能匹配字母数字下划线汉字,不能匹配除此之外的标点符号