在页面的末尾,试图解释贪婪、不情愿和占有量词是如何工作的: 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. 之间的确切区别是什么?