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:

param1=[^&]+&param2=[^&]+&param3=[^&]+$ 

Avoid using slow-performing quantifiers, as follows:

param1=.+&param2=.+param3=.+$ 

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.