Replace first space with comma space

A swapping-ground for Regular Expression syntax

Replace first space with comma space

Postby jratliff » Sat Oct 05, 2019 1:58 am

I would like to rename files such as:
William George Steven
Jones Amanda Lee

to:
William, George Steven
Jones, Amanda Lee

I looked through the forum for a way to do this but was unsuccessful. Any help is greatly appreciated.
jratliff
 
Posts: 2
Joined: Sat Oct 05, 2019 1:53 am

Re: Replace first space with comma space

Postby therube » Sat Oct 05, 2019 2:07 am

1:RegEx
Code: Select all
Match:  ^(.*?)\s(.*)
Replace:  \1, \2


Non-greedily match everything up to the first space
Eat the space
Match everything else
Add them back together with a ,<space> in between
therube
 
Posts: 657
Joined: Mon Jan 18, 2016 6:23 pm

Re: Replace first space with comma space

Postby jratliff » Sat Oct 05, 2019 2:31 am

Thank you so much. Works perfectly.
jratliff
 
Posts: 2
Joined: Sat Oct 05, 2019 1:53 am


Return to Regular Expressions


cron