I'm trying to find a dash - from a string if it match certain conditions and only the dash should be selected by regex.
Cases it should be selected -
test - dashtest- dashtest-dashCases that it shouldn't be selected
test -dashHere's my progress
as the screenshot shows, I can achieve with positive-lookbehind, but this is not widely supported.
So, my question is, is there an alternative way to achieve this without using positive-lookbehind?
Thanks.
For the example data, if you can not use a lookbehind perhaps it might suffice to use a word boundary.
-(?=\s)|\b-(?=[^\s-])
Explanation
-(?=\s) Match - and assert a whitespace char to the right| Or\b-(?=[^\s-]) Word boundary, match - and assert at the right a non whitespace char except -