Group capture in regular expressions
When the Use Regular Expressions option is checked, group capture allows you to isolate groups in the expression to be matched, so they can be captured and substituted during the replacement.
4+5*6+88
22+4*555
You can transform this expression to these patterns using group capturing:
(4+5)*(6+88)
and (22+4)*555
.
In the first expression there are four groups. First you must capture the individual groups in the expression by enclosing them in parenthesis. Specify that the characters are integers using the regular expression [0-9]+ (one or more integers). Use the escape character \ to indicate that the * and + symbols are literal and not meta characters.
Find text: ([0-9]+)\+([0-9]+)\*([0-9]+)\+([0-9]+)
Replace expression indicating the desired pattern and the
positions of the groups (numbered from left to right): (\1+\2)*(\3+\4)
Result: (4+5)*(6+88)