【发布时间】:2013-12-23 21:13:54
【问题描述】:
在页面的末尾,试图解释贪婪、不情愿和所有格的量词是如何工作的:http://docs.oracle.com/javase/tutorial/essential/regex/quant.html
但是我尝试了一个例子,但我似乎没有完全理解它。
我将直接粘贴我的结果:
Enter your regex: .*+foo
Enter input string to search: xfooxxxxxxfoo
No match found.
Enter your regex: (.*)+foo
Enter input string to search: xfooxxxxxxfoo
I found the text "xfooxxxxxxfoo" starting at index 0 and ending at index 13.
为什么是第一个reg.exp。找不到匹配项,而第二个匹配项呢? 这两个 reg.exp. 之间的确切区别是什么?
【问题讨论】:
标签: java regex greedy quantifiers