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
/
^-((?:(?:(?!{.*?})[^-\n]|{.*?})|(?:(?:(?!{.*?})[^-\n]|{.*?})*?-){2})*)-
/
gm
Unit Tests
basic 1
basic 2
ignore hyphens in braces 1
ignore hyphens in braces 2
match outermost even-numbered hyphens 1
match outermost even-numbered hyphens 2
match outermost and ignore hyphens in braces 1
match outermost and ignore hyphens in braces 2
manage unmatched braces 1
manage unmatched braces 2