I do not have much experience with regular expressions, but it probably because + is possessive. It will match all characters (because previous parts say so) until the end of string. There is no characters left, so attempt to match bb fails. Possessive quantifier does not backtrack, so it ends here. Try to use greedy quantifier (*) or lazy instead of possessive and use dot . for matching any character. Like that: aa.*bb
I found out that you need newlines in your match. I think there is way to force dot to match actully all, but some dialects support [^] as real "all symbols" character class.
Note, that aa[^]*bb will match xxaaxxxxxxbbxxxxbbxx
and aa[^]*?bb will match xxaaxxxxxxbbxxxxbbxx http://regexr.com?34r01 http://regexr.com?34r04
Choose what do you need.
some dialects support [^] as real "all symbols" character class.
The [^] seems to work fine, I should use that
But is this really caused by the quantifiers? I think if regex pattern("aa[\\s]+bb");
should work, then regex pattern("aa[\\sPUT_ANY_THING_HERE]+bb");
should also work, even regex pattern("aa[\\sb]+bb");
but why [\\s\\S]+ doesn't, \S stands for b here
they have the same quantifier.