黑马程序员技术交流社区
标题:
关于正则表达式的问题
[打印本页]
作者:
clock_c
时间:
2014-2-21 19:35
标题:
关于正则表达式的问题
本帖最后由 clock_c 于 2014-2-25 20:31 编辑
string pattern = @"--.*--";
string input = "He said--decisively--that the time--whatever time it was--had come.";
MatchCollection mc = Regex.Matches(input, pattern);
复制代码
话说为什么得不到我想要的
--decisively--
--that the time--
--whatever time it was--
而只是得到一个--decisiverly--呢
作者:
§風過無痕§
时间:
2014-2-21 22:59
string pattern = @"--.*--"; . 匹配除 "\n" 之外的任何单个字符 * 匹配前面的子表达式零次或多次
string input = "He said--decisively--that the time--whatever time it was--had come.";
--whatever time it was--单词之间有空格 当然匹配不出来啦! [a-zA-Z ]
作者:
clock_c
时间:
2014-2-22 07:59
§風過無痕§ 发表于 2014-2-21 22:59
string pattern = @"--.*--"; . 匹配除 "\n" 之外的任何单个字符 * 匹配前面的子表达式零次或 ...
原来是这样,谢谢啊
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2