Batch replace: Grab characters from elsewhere in the source?

General discussions about Advanced Find and Replace
Post Reply
RumMunkey
Posts: 3
Joined: Mon Jan 31, 2005 5:32 pm

Batch replace: Grab characters from elsewhere in the source?

Post by RumMunkey »

I have a batch configuration I run from time to time to edit code.

In the code, I have these 2 lines that appear like this:

SR:SC20050BOX
PR:3120001

...and this:

SR:SC20050BOX
PR:3120002

...and this:

SR:SC20050BOX
PR:3120003


...and so on. The last 3 digits of the "PR" line is a counter, basically. The numbers are unique, are always 3 digits, but not necessarily in numerical order.

I need to change the letters "BOX" to the 3-digits from the end of the "PR" line, so I end up with this instead:

SR:SC20050001
PR:3120001

SR:SC20050002
PR:3120002

SR:SC20050003
PR:3120003



Can AF&R do this? And how?

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Hi,

This is too easy task for AFR :)

Go to Batch Replace tab. Check ON "Use regular expressions"
Put search/replace pair:

Search for:
SR:SC20050BOX\r\nPR:3120(\d{3})

Replace with:
SR:SC20050$1\r\nPR:3120$1

That's all.

In this example we supposed that line delimiters are \r\n (usually used in Windows) and the text SR:SC20050BOX occupies whole line.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

RumMunkey
Posts: 3
Joined: Mon Jan 31, 2005 5:32 pm

Post by RumMunkey »

Thanks so much Roman!

Post Reply