Single Space Between Words and Hyphens

A swapping-ground for Regular Expression syntax

Single Space Between Words and Hyphens

Postby Shawnny Canuck » Sat Oct 10, 2015 1:21 am

Hello,

I am looking for some help with a RegEx that will ensure there are no spaces at the beginning and end of the file name/string and that there is a single space between each word and hyphen/dash (-)

For example,

Turn this: _____NAME1_______-__________________ NAME2_________-NAME3 (for this example _ represents a white space)
Into this: NAME1 - NAME2 - NAME3 (no white space before or after the file name)

and if it is a single word,

Turn this: NAME1_ (for this example _ represents a white space)
Into this: NAME1 (no white space before or after the file name)

Maybe this is not possible with a single RegEx? The number of NAMES can vary and if there is only one NAME I would like it to not have a space at the beginning and end so when I split the files there isn’t a white space in my file name. I hope that makes sense. Any help with this would be greatly appreciated.
Shawnny Canuck
 
Posts: 18
Joined: Wed Jul 30, 2014 7:15 pm

Re: Single Space Between Words and Hyphens

Postby Stefan » Sun Oct 11, 2015 4:29 pm

Hi,

have you checked out the option at "Remove(5)" ?
http://www.bulkrenameutility.co.uk/Shots/BRU_Main_Screen.gif




The help may provide more information.



 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Single Space Between Words and Hyphens

Postby Shawnny Canuck » Tue Oct 13, 2015 6:10 pm

Thanks Stefan I will look into it :)
Shawnny Canuck
 
Posts: 18
Joined: Wed Jul 30, 2014 7:15 pm


Return to Regular Expressions