change a "-" with a" "(only space) without changing " – "

A swapping-ground for Regular Expression syntax

change a "-" with a" "(only space) without changing " – "

Postby glennrune » Sat Jan 13, 2018 3:43 pm

Hello.


I need to change a "-" with a" "(only space) without changing " – " in the filename.
When I am using regex I cannot isolate "-" is there a way?
From
2016.11.29 - Monday - 5. Physics-5
2016.10.06 - Thursday – 1-Environmental costs
To:
2016.11.29 - Monday - 5. Physics 5
2016.10.06 - Thursday – 1 Environmental costs
glennrune
 
Posts: 7
Joined: Thu Dec 28, 2017 4:45 pm

Re: change a "-" with a" "(only space) without changing " – "

Postby therube » Mon Jan 15, 2018 6:18 pm

See if this gets it:

1:RegEx
Code: Select all
Match:  (.*?\S)-(\S.*)
Replace:  \1 \2
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: change a "-" with a" "(only space) without changing " – "

Postby Jack2 » Thu Nov 15, 2018 12:36 pm

I also had a need for this, and I can confirm that it works fine, thanks.

.
.
btw, for anyone else wanting to use it in the future, if it's not obvious, note that it only replaces the first hyphen. You will have to run it two/three/four times if you are trying to get rid of multiple hyphens in the same filename.
Jack2
 
Posts: 30
Joined: Wed Nov 14, 2018 4:32 pm


Return to Regular Expressions