17Search and replace
Use groups in the replacement: $1, $2 and $<name> rearrange text.
Regexes shine when you replace text. In the replacement string, $1 inserts what group 1 matched, $<name> a named group and $& the whole match (Java uses ${name} and $0).
To turn Smith, John into John Smith: pattern (\w+), (\w+), replacement $2 $1. In the tester, switch the function on the left to Substitution to try it on your own text.
Exercises
Lesson complete – well done!