Use a negated character class instead of the greedy and slow .* or .+

Wherever possible, use negated character classes instead of the potential performance draining patterns (.* or .+), as follows:


Avoid using slow-performing quantifiers, as follows:


Get Java 9 Regular Expressions now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.