regex group dynamic replace
Posted: Thu Apr 27, 2006 3:08 pm
I have been writing a program that I use to rename files (in VB6). I can successfully use the regexp object, but I would like to do something with it that I don't see how to accomplish it - specifically, a 'transform' on a backreference, for lack of a better term.
I often work on a group of files that have a sequential number in them for ordering purpose, but sometimes I want to insert a file. I can easily identify the number, but how can I renumber it?
Example:
It's easy enough to find what needs to change
regex = ^(Log)(\d\d)(Apr06\.txt)
$2 will contain what I want to transform, but can it be done?
I often work on a group of files that have a sequential number in them for ordering purpose, but sometimes I want to insert a file. I can easily identify the number, but how can I renumber it?
Example:
Code: Select all
Old File New File
Log02Apr06.txt Log03Apr06.txt
Log03Apr06.txt Log04Apr06.txt
Log04Apr06.txt Log06Apr06.txtregex = ^(Log)(\d\d)(Apr06\.txt)
$2 will contain what I want to transform, but can it be done?