Extract common repeating substrings out of alternation

Consider the following pattern:

(playground|player|playing) 

Instead of using the preceding pattern, it is better to extract the common substring, play, and move it to the left of alternation, as follows:

play(ground|er|ing) 

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.