Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
r"
\b(?<!-)\w+-\B|\B-\w+\b(?!-)
"
gm
Input 1
1
New
here are -some- word sub-words -word1 word2- sub-word2 word3- -word4 -word5 example word6- word7- another one -word8 -word9