The syntax for substitutions is simple. For example the python "S" command can be used to change a string matched by a regex to the substitute, another string.
In very complex patterns, we'll want to use more than one register; here's an example where we first capture two strings, and then refer to them both in order.
The parenthesis and number operators can also specify that a certain string or expression must occur twice in the text.
For example, suppose we are looking for the pattern “the Xer they were, the Xer they will be”, where we want to constrain the two X’s to be the same string. We do this by surrounding the first X with the parenthesis operator, and replacing the second X with the number operator \1, as follows: /the (.*)er they were, the \1er they will be/