reorder and add in hypens for this particular case

A swapping-ground for Regular Expression syntax

reorder and add in hypens for this particular case

Postby angeltread » Thu Jun 26, 2025 11:39 am

i need some rearranging....
so i got a files like....

John Doe 19990131 Title With Various Number Of Words 1 3 Kate Smith.txt

the names at the beginning and the end are always 2 words.
the date is consistent in that format of year month day in digit form.
the title is always the a various number of words but is always followed by a single digit and then another single digit

and i want it to be arranged like so.

Kate Smith - 1999-01-31 - John Doe - Title With Various Number Of Words #01 ver3.txt

anyone can help me. still learning this thing but i like what i have figured out thus far. cant figure this one out yet though.
angeltread
 
Posts: 7
Joined: Fri Aug 07, 2020 12:03 am

Re: reorder and add in hypens for this particular case

Postby Admin » Thu Jun 26, 2025 11:57 am

Admin
Site Admin
 
Posts: 2938
Joined: Tue Mar 08, 2005 8:39 pm

Reorder and insert characters

Postby Luuk » Fri Jun 27, 2025 1:00 pm

Remember if the AI gets examples with having file-extensions, then his regexs will try to match them!
So the easiest way to make his answer conduct properly, is to use both checkmarks for "v2" and "Inc.Ext."
Then just remove $11 from his "Replace" (easier than "Renaming Options, File/FolderExtension, Rename File Extensions")

Another way with only the "v2" checkmark, is just remove his last (group) from "Match" and $11 from "Replace".
Another way without any checkmarks, could be a "Match" and "Replace" like...

^((?:[^ ]+ ){2})(\d{4})(\d\d)(\d\d)(.+)(\d )(\d) ([^ ]+ [^ ]+)$
\8 - \2-\3-\4 - \1 - \5 #0\6 ver\7

John Doe 19990131 Varying Number Of Words 1 3 Kate Smith ---> Kate Smith - 1999-01-31 - John Doe - Varying Number Of Words #01 ver3
Luuk
 
Posts: 815
Joined: Fri Feb 21, 2020 10:58 pm


Return to Regular Expressions