You need to pick the \d+
inside ()
to capture in group($1
)
\by[(\d+)]
Also, you may need to to escape the [
and ]
characters here.
\by\[(\d+)\]
Question
I'd like to replace this
y[100]
with this Ith(y,100)
in Sublime3.
I've got the regular expression \by[\d+]
in find what and Ith(y,$1)
in replace with, but it doesn't work. It finds what to replace correctly but just replaces it with Ith(y, )
Solution
You need to pick the \d+
inside ()
to capture in group($1
)
\by[(\d+)]
Also, you may need to to escape the [
and ]
characters here.
\by\[(\d+)\]
OTHER TIPS
You have to capture the data you want to backreference: to do that you have to use unescaped parenthesis (...)
, ie capturing groups. Also, [...]
are character classes, a special character in regex that you need to escape.
Try replacing
\by\[(\d+)\]
with
Ith(y, \1)
You need to escape the special characters and capture the number in a capturing group group. Try this regex:
\by\[(\d+)]\b
And replace with
Ith(y, $1)
Online explanation and demonstration: http://regex101.com/r/nX3yJ9