By defaut, regex are greedy in Java. Adding a ? makes the regex non greedy.
A.*c # greedy : AbcAbc is matched in AbcAbc
A.*?c # non greedy : Abc is matched in AbcAbc
Important : negative look-ahead does not consume characters !
q(?!u) # match q in "Iraq", but does not match q in "quit"
(?:X) # X is the pattern