SOLVED: [10.60b2] Problem with regex replace

Post bug reports when testing beta versions here.
Post Reply
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

SOLVED: [10.60b2] Problem with regex replace

Post 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?
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
crtrubshaw
Posts: 322
Joined: 06 Jun 2012 11:08

Re: [10.60b2] Problem with regex replace

Post by crtrubshaw »

You should put the capture groups in brackets, then you can use them as backreferences:

(\d{2}) - (\d{2})
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: [10.60b2] Problem with regex replace

Post by pjj »

You are absolutely right! I forgot about brackets :oops: Thank you!
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
Post Reply