左右括号‘(’‘)’配对的正则表达式 a=string.indexof("(")b=string.lastindexof(")")string.substring(a-1,b-a) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 icehawk(我是一只小小鸟) 我不是要查询子字符串,我是要写这样的正则表达式 string cutText = "已知的字符串"; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\((?<str>[\w\(\)]+)\)+"); System.Text.RegularExpressions.Match match = regex.Match(cutText); if(match.Success) { MessageBox.Show(match.Groups["str"].Value); } 谢谢 showtimenow(景)你的解答还是没有解决我的问题我想正则表达式也不是万能的,他并不能实现动态匹配 看看这样是你的要求吗? string cutText = this.textBox1.Text; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\((?<str>.*)\)+"); System.Text.RegularExpressions.Match match = regex.Match(cutText); if(match.Success) { MessageBox.Show(match.Groups["str"].Value); } 把每一个(xxx)取出来,然后地规调用 TO: qianli918(千里马)其实也不是要实现什么,我只是想看看 正则表达式是否有这样的功能 showtimenow(景)匹配出来的有严重问题如:abcd(4348743747))结果是:4348743747)应该是:4348743747 ORACLE存储过程怎么执行? C# 求关键路径 xmlwrite问题 为何说这段代码有错误? 如何控制C#开发的程序只能试用一个月? C# 打包程序 C#怎么样调用Liunk下的MySQL数据库 ###大哥帮帮忙,急!关于ActiveX控件### C#多线程操作list对象,急!!!! button点击事件导致TextBox失去焦点,无法调用TextBox的lostfocus事件 请教 如何设置使csc.exe手动关闭
我不是要查询子字符串,我是要写这样的正则表达式
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\((?<str>[\w\(\)]+)\)+");
System.Text.RegularExpressions.Match match = regex.Match(cutText);
if(match.Success)
{
MessageBox.Show(match.Groups["str"].Value);
}
string cutText = this.textBox1.Text;
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\((?<str>.*)\)+");
System.Text.RegularExpressions.Match match = regex.Match(cutText);
if(match.Success)
{
MessageBox.Show(match.Groups["str"].Value);
}
如:abcd(4348743747))
结果是:4348743747)
应该是:4348743747