I'm new to Regex in PHP. I suspect this will have a quick answer.
I have:
"Field A: result xyz, Field B: result123, Field C: and this is another result "
I need:
"Field A:result xyz,Field B:result123,Field C:and this is another result "
...so basically I want to:
- remove all double spaces, and,
- remove all single spaces if preceded by
:
or,
My RegEx:
- Pattern:
([ :,])\s+
- Replace:
${1}
...works in Notepad++:
...and seems like it would work on regex101.com
(if I knew how to actually replace on there):
...but in PHP with preg-replace
, different variations of the pattern I've tried are telling me:
Unknown modifier '['
or Unknown modifier '\'
or Unknown modifier '+'
...and I'm confident would work in VBA too. Here's the cheatsheet I use but obviously it doesn't all apply to PHP...
Thoughts, please & thanks?