#1 2017-08-23 04:59

tom.amitai
Member
Registered: 2013-04-18
Posts: 5

Replace even numbered occurrence of space

I have files with names in their names, like "Joe Blow Sam Hill Tom Jones", and I would like to change them to "Joe Blow, Sam Hill, Tom Jones".  The number of names in each file name is not the same.  Can this be done?

Offline

#2 2017-08-23 08:06

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

Re: Replace even numbered occurrence of space

Hi Tom,

tom.amitai wrote:

...Can this be done?

Yes, if you can provide a common pattern how to find the position to insert the comma.
Or perhaps, if you can provide a list of names to find and then we add trailing comma after each.




 


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 2017-08-23 09:42

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

Re: Replace even numbered occurrence of space

For example, considering your example, you can insert a comma after every 2 consecutive capitalized words.

Using the following Regular Expressions rule:

Replace expression "([A-Z]\w+)(\s+)([A-Z]\w+)\b(.)" with "$1$2$3,$4" (case sensitive) (skip extension)

Input:

Joe Blow Sam Hill Tom Jones

Output:

Joe Blow, Sam Hill, Tom Jones

Offline

#4 2017-08-23 18:56

tom.amitai
Member
Registered: 2013-04-18
Posts: 5

Re: Replace even numbered occurrence of space

den4b wrote:

For example, considering your example, you can insert a comma after every 2 consecutive capitalized words.

Using the following Regular Expressions rule:

Replace expression "([A-Z]\w+)(\s+)([A-Z]\w+)\b(.)" with "$1$2$3,$4" (case sensitive) (skip extension)

Input:

Joe Blow Sam Hill Tom Jones

Output:

Joe Blow, Sam Hill, Tom Jones


Thanks, that did it!  Regexes give me a headache, they look like what happens when my cat walks on the keyboard!

Offline

#5 2017-08-24 11:18

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

Re: Replace even numbered occurrence of space

tom.amitai wrote:

Regexes give me a headache, they look like what happens when my cat walks on the keyboard!

lol

Offline

Board footer

Powered by FluxBB