At the end of the page there is an attempt to explain how greedy, reluctant, and possessive quantifiers work: http://docs.oracle.com/javase/tutorial/essential/regex/quant.html
However, I tried the example itself, and I don't seem to understand it completely.
I will embed my results directly:
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.
Why the first reg.exp. not find a match, but the second one does? What is the exact difference between these 2 reg.exp.?
+ , " regex , ". (. .)
+
, .*foo "xfooxxxxxxfoo", .* . , foo , regex , , .* "xfooxxxxxx" foo "foo".
.*foo
"xfooxxxxxxfoo"
.*
foo
"xfooxxxxxx"
"foo"
+ , .
(.*)+foo. + ; " ". , , , , . , "xfoxxxxxxxxxfox", .
(.*)+foo
"xfoxxxxxxxxxfox"
, , . xfooxxxxxxfoo .*+, foo, , .
.*+
, "" :
xfooxxxxxxfoo fail xfooxxxxxxfo fail xfooxxxxxxf fail xfooxxxxxx match
- , . " (. *)", + (), .