Moving four digits to the start of the filename.

A swapping-ground for Regular Expression syntax

Moving four digits to the start of the filename.

Postby noonand » Sun Sep 15, 2013 8:18 pm

Hello all,

I have searched prior to posting but couldn't find something that would work for me

If I have a bunch of filenames with names like this_is_the_filename_nnnn_nn%.ext where nnnn is a four digit year what regexp would I need to use to move nnnn to start of the filename.

While the nn% is there in most cases there are a few edge cases that it is not so I can't use the $ to constrain to the end of the file. I know I should use {\d4} to get where there are four digits together but after that I'm at a loss as to where to proceed.

- Derek
noonand
 
Posts: 2
Joined: Sun Sep 15, 2013 8:12 pm

Re: Moving four digits to the start of the filename.

Postby noonand » Sun Sep 15, 2013 9:00 pm

Match: (.+)_(\d{4})(.+)%
Replace: \2_\1\3%

It just required a little time to play with it.

Thanks!
noonand
 
Posts: 2
Joined: Sun Sep 15, 2013 8:12 pm


Return to Regular Expressions