#1 2017-10-31 15:29

brians304
Member
Registered: 2017-10-31
Posts: 2

REGEX move yyyymm to first word

Good day all,

I am way past my self imposed limit of 8 hours of trying to get something to work. I searched every regex post here I could think of and didn't find anything that worked.

My sample folders are below. I want to find the yyyymm in the folder name and move IT to the first word plus a "-" and then remove it from the filename. I used (\d\d\d\d\d\d) this to find it, but no combination of $n to $x places it correctly. I used the denb4 regex checker and anywhere else google put me. very very frustrated......

birds-film-herrick-200107-n400 to 200107-birds-film-herrick-n400
brenwood-200310-m7-65mm-tri-x to 200310-brenwood-m7-65mm-tri-x

thank you in advance!!!!!
Brian

Offline

#2 2017-10-31 15:51

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,370

Re: REGEX move yyyymm to first word

Good day to you too, Brian.

You will achieve what you want by using the following regular expression:

\A(.*?)-?(\d{6})-?(.*)\Z

With the following replacement pattern:

$2-$1-$3

Offline

#3 2017-10-31 16:37

brians304
Member
Registered: 2017-10-31
Posts: 2

Re: REGEX move yyyymm to first word

Could answer faster next time? ;-]]] Thank you so much. It is no wonder I couldn't get it to work.
All the best,
Brian

Offline

Board footer

Powered by FluxBB