by truth » Wed Nov 13, 2013 1:41 am
No worries,
There is a good primer to regexes @ www.bulkrenameutility.co.uk/forum/viewtopic.php?f=3&t=96
Best way to learn is by trying-out different Match/Replacements in BRU (with Options/AutoSelect-Checked)
It gives you some visual feedback as you change the different parts, just keep them simple to start with.
I'll do by best with this example:
Match: (.*?) - (.*)
Repla: \1-\2
Text-strings can be grouped within ()
When text is grouped, you can represent that text with \1, \2, \3, etc in the ReplaceBox
To represent what text gets matched, you can either type the literal text, or use wildcards
An example: To match abc, you could use abc or ... (the .'s are wildcards, meaning any-3chars whatsoever)
With wildcards, you often want to specify a range of how-many chars to match:
.* match 0-or-more, but as many as possible (without disabling an upcoming match, thats where it'll stop)
.+ match 1-or-more (same as above)
.+? match 1-or-more (but as few chars as possible, until next upcoming match succeeds)
So in this example, your match is: (AsFewCharsAsPossible)Space-Space(AsManyAsPoss)
We didnt group Space-Space within () because that's the part you want to edit in Replace (killing the spaces)
Thus a replacement of:\1-\2
Another way is to match: (AsFewCharsAsPossible)Space(-)Space(AsManyAsPoss) and replace with \1\2\3
(.*?) (-) (.*)
\1\2\3
Notice how the non-grouped text gets discarded, unless typed back into the replacement
Theres a bit more to it, but its not really complicated.. Again, the best way to learn is while in BRU
Just dont forget to at least put \1 into your replace so you see how your matching changes.
A final example, it only matches filenames beginning as CapCap###Space-Space
(so it wont touch any files you may have already renamed)
^([A-Z]{2}[0-9]{3}) (-) (.*)
\1\2\3