Replace the text with searched text with \1

Solved bugs are moved into this topic...
Post Reply
hycmos
Posts: 86
Joined: 06.11.2019 02:17

Replace the text with searched text with \1

Post by hycmos »

For example,
original text: 12.3
wanted text: 1.23

So I Ctrl+R, (click option:regular expressions)
Find input-box:(\d)\.
Replace input-box:\.\1

but the result is:1.13 not 1.23
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Docs for regex
https://regex.sorokin.engineer/en/lates ... substitute
shows that you must use $1, not \1.
hycmos
Posts: 86
Joined: 06.11.2019 02:17

Post by hycmos »

Thanks.
I don't know the symbol '$1' is used to denote the subexpression 1.
I used '\1' for that.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

\1 is used in Regex (backreference). $1 is used in "replace with".
Post Reply