Reputation: 18804
I will try to explain my situation with an example, consider the following string:
03 - The-Basics-of-Querying-the-Dom.mov
I need to remove all -
s (hyphens) excluding the one after the digits. In other words, all hyphens in between the words.
This is the REGEX I created: /([^\s])\-/
. But the problem is, when I try to replace, the character before the space is also removed.
Following the result I am aiming for:
03 - The Basics of Querying the Dom.mov
Think, I can use something like exclude groups? I tried to use ?:
& ?!
in the capture group to avoid it from being matched, but didn't give any positive results.
Upvotes: 0
Views: 43
Reputation: 48711
I just modified your already proposed RegEx by using a positive lookbehind (which only asserts the correct position):
/(?<=[^\s])\-/
Upvotes: 0