In the pattern below, I need to put a single space before and after the dash. The part numbers will differ in each replacement but the rest of the string is always the same. I know very little about regex but am using a Wordpress plugin to do this (the database is backed-up :) It's simply asking for the regex string/formula.
Part #8208-#8212 needs to be changed to Part #8208 - #8212
Thanks
CodePudding user response:
I think that should do the trick:
'Part #8208-#8212 needs to be changed to Part #8208 - #8212'
.replace(/(\S)-(\S)/g, '$1 - $2')