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
/
([^\s\d])(-\s+)
/
gm
Input 1
1
New
This is a text with a hyphen- ated word in the middle of the sen- tence. But it also has - dashes - like the ones in the second sentence. The latter should not be modified. 1. 2001-ben (in 2001). Hyphen should not be re- moved if it is preceded by a number. 2. 8-10. Hyphen should not be removed when it connects two numbers. 3. Szükséges-e (Is it needed)
Substitution
$1
This is a text with a hyphen- ated word in the middle of the sen- tence. But it also has - dashes - like the ones in the second sentence. The latter should not be modified. 1. 2001-ben (in 2001). Hyphen should not be re- moved if it is preceded by a number. 2. 8-10. Hyphen should not be removed when it connects two numbers. 3. Szükséges-e (Is it needed)