I'm a total RegEx newbie and need some help!
I have a directory with hundreds of file names in this format:
Prefix-CityName-St-Country-Date
The problem I have is that CityName can be 1, 2, or 3 words, separated by dashes. I need it to be changed to one word. There are about 70 multiple word city names.
Examples:
Prefix-City-Name-St-Country-Date needs to be changed to Prefix-CityName-St-Country-Date
Prefix-3Word-City-Name-St-Country-Date must be changed to Prefix-3WordCityName-St-Country-Date
I tried to do this but was unable to: I know nothing about RegEx!
Anyone able to help?
Thanks very much,
John
RegEx Newbie
Re: RegEx Newbie
This can be achieved with the following regular expression
search for: ([^-]+-[^-]+)(-([^-]+))?(-([^-]+))?(-[^-]+-[^-]+-[^-]+)
replace with: $1$3$5$6
Do not forget to activate the checkbox "Regular expression"
search for: ([^-]+-[^-]+)(-([^-]+))?(-([^-]+))?(-[^-]+-[^-]+-[^-]+)
replace with: $1$3$5$6
Do not forget to activate the checkbox "Regular expression"
Re: RegEx Newbie
Thanks very much @matandra, I will try that out when I have a couple of minutes!
John
John
Who is online
Users browsing this forum: No registered users and 46 guests