How can I find the space before and after hyphenated words? i.e. "This is my hyphenated-word example test"
I need the space between: "my hyphenated-word" and "hyphenated-word example"
How can I find the space before and after hyphenated words? i.e. "This is my hyphenated-word example test"
I need the space between: "my hyphenated-word" and "hyphenated-word example"
You can use lookahead and lookbehind.
The space before:
\s(?=([^\s]+-[^\s]+))
The space after:
(?<=([^\s]+-[^\s]+))\s
in case you just want to get the hyphenated-word itself, retrieve the whole match (e.g. capturing group 0) with this regex:
\w+(?:-\w+)+