Ok, I have a pretty tricky regex problem.
I need to match and replace the + signs in the following strings with whitespace, thus the strings on the left must become the strings on the right.
1: word+word = word word
2: word+++word = word + word
3: word.+word = word. word
4: word,+word = word, word
I’ve managed to nail most of ’em with this, which checks for strings before and after plus signs:
(?<=[\w\.,])\+(?=[\w])
However, I can only nail one set of the adjacent plus signs in (2) at a time:
(?<=[\w\.,\+])\+(?=[\w]) // gets the left plus sign
2: word+++word = word++ word
(?<=[\w\.,])\+(?=[\w\+]) // gets the right plus sign
2: word+++word = word ++word
In my current regex be-frazzled state, I’m wondering if I need to wrap the pattern in a larger condition, or if I need to implement an either or pattern in the lookarounds. Any regex mavens out there care to give this a whirl?
This should work on your examples:
Replace that with spaces.
Example:
Outputs: