M-C-% \(([[:digit:]]+)\) RET fixed text \1 RET !
RET means to press the return key.
- M-C-% runs the command query-replace-regexp in a typical Emacs.
\(([[:digit:]]+)\) is the regexp for the occurances to be found like e.g. (1), (2) or (42).
[:digit:] is the character class for digits. See e.g. the Elisp info pages for more.
[[:digit:]] stands for any single digit in the regexp like
[[:digit:]]+ stands for any sequence of digits.
([[:digit:]]+) stands for any sequence of digits within parenthesis.
- And the surrounding quoted parenthesis define group 1 for each match which allows to reference the match in the replacement part. See below.
fixed text \1 is the replacement part which consists of the fixed text and
\1 which is the way to reference the group 1 match.
- The final
! let's Emacs replace all further occurances in one go.
Note the hint in the comments about
\& in the replacement part stands for the whole match. This is applicable in the given case. Explicit grouping is not necessary here.
Concretely one could use
M-C-% ([[:digit:]]+) RET fixed text \& RET !
for the given task.
The explicit grouping is more flexible, tho.