正则表达式问题,取指定字符中间的值!! <li> ${username}$ ${userpwd}$ </li>怎么得到 ${ 和 }$ 之间的内容?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Regex reg = new Regex(@"<book>(.*?)</book>", RegexOptions.Singleline | RegexOptions.IgnoreCase); MatchCollection matches = reg.Matches(字符串名称); foreach (Match match in matches) { book.Cart = "<book>" + match.Groups[1].Value + "</book>"; } string test = "<li> ${username}$ ${userpwd}$ </li> "; MatchCollection mc = Regex.Matches(test, @"(?<=\$\{)[^}]*(?=}\$)"); foreach (Match m in mc) { Response.Write(m.Value + "<br>"); } 同楼上,不过正则表达式可以再简化一下 MatchCollection mc = Regex.Matches(test, @"(?<=\$\{)[^}]*");//针对大刮号一定会成对出现的情况 //或者有下式 MatchCollection mc = Regex.Matches(test, @"(?<=\$\{).*?(?=}\$)"");/ ASP.Net中的一个小问题! 关闭弹出窗口并改变父页控件值的问题? 大虾帮一把啊,在线等,解决马上给分啦 隐藏CheckBox的text值请问如何处理? 奇怪,难道闹鬼了? 如何实现跨站点操作?javaScript能做到吗?非常现实试用的问题,请高手支招 web程序开发的人多么 VB.NET里RadioButton的AutoPostBack属性问题(急求) vs2005调试项目时怎么报个空白错误! 怎么得到DATAGRID数据的行数? IE7框架问题 在.NET中如何执行带参数的sql语句
MatchCollection matches = reg.Matches(字符串名称);
foreach (Match match in matches)
{
book.Cart = "<book>" + match.Groups[1].Value + "</book>";
}
MatchCollection mc = Regex.Matches(test, @"(?<=\$\{)[^}]*(?=}\$)");
foreach (Match m in mc)
{
Response.Write(m.Value + "<br>");
}
MatchCollection mc = Regex.Matches(test, @"(?<=\$\{).*?(?=}\$)"");/