Page 1 of 1

SOLVED: [10.60b2] Problem with regex replace

Posted: 18 Aug 2015 08:12
by pjj
I just noticed I can't use backreferences in regex replace. I have this regex

Code: Select all

\d{2} - \d{2}
to mach lines like

Code: Select all

25 - 30
Alas, with replace field equal to e.g.

Code: Select all

$1#$2
this line -- correctly recognized -- is replaced with the very same "replace" value, i.e.

Code: Select all

$1#$2
instead of expected

Code: Select all

25#30
Could you please look into it?

Re: [10.60b2] Problem with regex replace

Posted: 18 Aug 2015 09:48
by crtrubshaw
You should put the capture groups in brackets, then you can use them as backreferences:

(\d{2}) - (\d{2})

Re: [10.60b2] Problem with regex replace

Posted: 18 Aug 2015 10:16
by pjj
You are absolutely right! I forgot about brackets :oops: Thank you!