Regular match Just Once (no repetition)
I faced this little regex problem (flags: Global)
[-+*&|]
It must match, for example, + in this expression, but not ++ or -:
12 + 47 - i++ / --foo
However, it fits all of these.
I am aware of this solution, but it is ugly (needs to be repeated three times):
[^-+*&|][-+*&|][^-+*&|]
Or perhaps
(?<![-+*&|])([-+*&|])(?![-+*&|])
Any better (shorter and more readable) solution?
+3
source to share