#1 2011-11-01 20:18

pstein
Member
Registered: 2006-10-28
Posts: 43

RegExp question yyyy<---->mm switch

I need help setting up a RegExp.

I have a couple of files which contain a date pattern (no day):

yyyy mm
or
yyyy.mm

I want to put now month BEFORE year part:

mm.yyyy

In target pattern there should be in all cases a dot between mm and yyyy
regardless whether there was a dot in source pattern or not.

How can I write such a RegExp?

Thank you
Peter

Offline

#2 2011-11-01 21:31

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: RegExp question yyyy<---->mm switch

pstein wrote:

I need help setting up a RegExp.

I have a couple of files which contain a date pattern (no day):

yyyy mm
or
yyyy.mm

I want to put now month BEFORE year part:

mm.yyyy

In target pattern there should be in all cases a dot between mm and yyyy
regardless whether there was a dot in source pattern or not.

How can I write such a RegExp?

Thank you
Peter


Depends on the rest of the original name. Are this the only digits in all files?

Well, perhaps we have luck and it works as we will match 4digits/2digits in an row.

FROM:
Any signs YYYY.MM Any signs
TO:
Any signs MM.YYYY Any signs
DO:

Match all signs: (.+) and store in group 1
Match four digits: (\d\d\d\d) and store in group 2
Match an space or an dot: (\s|\.) and store in group 3
Match two digits: (\d\d) and store in group 4
Match all signs: (.+) and store in group 5


So search for: (.+) (\d\d\d\d)(\s|\.)(\d\d) (.+)  adding needed space or not between groups yourself.
Replace as you need: $1 $4.$2 $5  adding needed space or dot between groups yourself.


HTH?


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2011-11-02 13:09

pstein
Member
Registered: 2006-10-28
Posts: 43

Re: RegExp question yyyy<---->mm switch

works :-)

Offline

Board footer

Powered by FluxBB