Newbie to regex

A swapping-ground for Regular Expression syntax

Newbie to regex

Postby laconic » Mon Oct 25, 2010 2:24 am

Hi.
I've been using this great product for months now but mainly for simple rename operations. I am trying to learn renaming using regex and I can't get my first attempt off the ground. I think I may not be ticking or pressing something.

I'm trying to remove a group of 3 digits from the beginning of a group of files.

Filenames are like this "234 filename.avi"

In the "RegEx(1)" I'm trying to match with \d{3} and using anything like xxxx just as a test in the replace box.

but this results in showing all highlighted files being potentially renamed to xxxx.avi

What am I not doing?
laconic
 
Posts: 2
Joined: Mon Oct 25, 2010 2:18 am

Re: Newbie to regex

Postby Stefan » Mon Oct 25, 2010 8:27 pm

For BRU you have to match the whole string (file name), not only the part you want to edit.

Match three digits, then an blank. Since we wanna remove them, we don't have to ()-group this for back references.
Then match the rest of the string. We have to ()-group this for back references, because this is the part we want to keep (used as replacement).


FROM
"234 filename.avi"
TO
"filename.avi"
DO
RegEx(1)
Match: "\d{3} (.+)"
Repla: "\1"
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Newbie to regex

Postby laconic » Tue Oct 26, 2010 1:23 am

Oh that makes perfect sense :-) I'm sorry.

Thanks for the reply.
laconic
 
Posts: 2
Joined: Mon Oct 25, 2010 2:18 am


Return to Regular Expressions