Add a space b4 any Capital Letter after the 23rd character

A swapping-ground for Regular Expression syntax

Add a space b4 any Capital Letter after the 23rd character

Postby Jack2 » Sun Dec 20, 2020 2:23 am

Hi
I want to change

ConstantWord-20200207-CarBusTrain
ConstantWord-20200324-ApplesOrangesBananasMangosPearsPeanutsCapsicums

into
ConstantWord-20200207-Car Bus Train
ConstantWord-20200324-Apples Oranges Bananas Mangos Pears Peanuts Capsicums

i.e.
I want to add a space before every capital letter after the 23rd character.
(which is equivalent to)
I want to add a space before the second and every subsequent capital letter after the date.

--
that is, generically,

from:
ConstantWord-yyyymmdd-VariablewordoneVariablewordtwoVariablewordthreeVariablewordfourVariablewordfive

into:
ConstantWord-yyyymmdd-Variablewordone Variablewordtwo Variablewordthree Variablewordfour Variablewordfive

Where
ConstantWord is the same alphastring in every file. The first and eigth characters are always capitals
yyyymmdd is the date in numerics and is different in every file
and
Variablewordone etc are all alpha characters, the words are all different from each other and different in every file and always start with a Capital letter. There is a different number of Variablewords in each file, but there are usually 6 to 12 of them

--

I have got this far
Find: (ConstantWord-[0-9].*?-)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?)([A-Z])(.*?) etc
Replace: \1-\2-\3 \5\6 \7\8 \9\10

(where ([A-Z])(.*?) successfully matches a word that starts with a Capitalletter)


...but this is no good as
1) BRU has a maximum of 9 terms for resorting in Regex and there are often more than 9 terms in the file
2)It only matches when there are the same number of Variablewords in the filename as there is in the Findterm. I want it to work whatever the number of Variablewords

is there another way to do it?

I don't particularly want to change ConstantWord into Constant Word, but if it makes life easier, I can do so, then manually change it back with a regular search and replace, as it is always the same string.

Same goes for -Variablewordone (I don't particularly want to change it to - Variablewordone, but can do, if necessary)

thanks
Jack2
 
Posts: 30
Joined: Wed Nov 14, 2018 4:32 pm

Re: Add a space b4 any Capital Letter after the 23rd character

Postby Luuk » Sun Dec 20, 2020 6:55 am

Greetings Jack2. There was good post on how to do this, but now Im not finding it anywhere? Im posting back when to find it.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Add a space b4 any Capital Letter after the 23rd character

Postby Luuk » Sun Dec 20, 2020 12:15 pm

This the links Im find after much searching, but yours is only similiar to both of them ....
http://www.bulkrenameutility.co.uk/foru ... f=3&t=3061
http://www.bulkrenameutility.co.uk/foru ... =11&t=4759
After much editing the solutions, they still not conduct like your explanation, so maybe you can have better luck with the edits.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Add a space b4 any Capital Letter after the 23rd character

Postby Admin » Sun Dec 20, 2020 12:30 pm

With Javascript in BRU:
- go to 27th char
- If capital letter add a space before it
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Add a space b4 any Capital Letter after the 23rd character

Postby Jack2 » Mon Dec 21, 2020 4:20 am

Luuk wrote:This the links Im find after much searching, but yours is only similiar to both of them ....
http://www.bulkrenameutility.co.uk/foru ... f=3&t=3061


Thanks all. I wrestled with the regex a bit, but also saw that the first link mentioned
7:Add -> Word Space
which adds a space before all capitals, which is easier (and I can also easily get rid of the couple of unwanted spaces it adds ).

I will come back to the regex another day.
thanks
Jack2
 
Posts: 30
Joined: Wed Nov 14, 2018 4:32 pm


Return to Regular Expressions