求正则表达式 匹配如下3个,请问分别怎么写?1.肯德基(***)2.肯德基****3.***肯德基 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 忘记说了 *随便为什么另外问个问题。我匹配肯德基(***) 用 string matchString = string.Format(@"^({0}\(.+\))$","肯德基");这样可以吗? 1. \s*肯德基[(](?<s>[^)]+)[)]2. \s*肯德基(?<s>[^.]+)3. \s*(?<s>[^.]+)肯德基 第一个匹配有问题,应该为 string matchString=@"^肯德基\(...\)$"; Regex regex = new Regex(matchString); bool result = regex.IsMatch("肯德基(***)"); Console.WriteLine(result); matchString = "^肯德基....$"; regex = new Regex(matchString); result = regex.IsMatch("肯德基****"); Console.WriteLine(result); matchString = "^...肯德基$"; regex = new Regex(matchString); result = regex.IsMatch("***肯德基"); Console.WriteLine(result);http://field.cnblogs.com/archive/2006/07/14/450373.html 关闭浏览器session变为空的问题 WPF中ListBox如何自动滚屏 c#无法进入DLL进行断点调试? c# 查询sql 超时时间已到。 我是新手!怎么学习.net ? 懂得CAD二次开发的请进. .NET2003 DataGrid的TableStyle 我在绑定datagrid 的模板列里面, 因为此列要显示金额, 所以我将形式设为 dataformatstring={0:c}, 但是显示出来的结果没有小数点, 请问怎 两表间数据处理 问个C# 的最基础问题,进者就有分,在线等 thread几个简单问题 ... 学习.NET(C#)什么教材比较好?
我匹配肯德基(***) 用 string matchString = string.Format(@"^({0}\(.+\))$","肯德基");这样可以吗?
1. \s*肯德基[(](?<s>[^)]+)[)]
2. \s*肯德基(?<s>[^.]+)
3. \s*(?<s>[^.]+)肯德基
string matchString=@"^肯德基\(...\)$";
Regex regex = new Regex(matchString);
bool result = regex.IsMatch("肯德基(***)");
Console.WriteLine(result); matchString = "^肯德基....$";
regex = new Regex(matchString);
result = regex.IsMatch("肯德基****");
Console.WriteLine(result); matchString = "^...肯德基$";
regex = new Regex(matchString);
result = regex.IsMatch("***肯德基");
Console.WriteLine(result);http://field.cnblogs.com/archive/2006/07/14/450373.html