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"
\s*(?:\[[^][]*]|\([^()]*\))\s*$
"
gm
Input 1
1
New
Old Macdonald had a farm [Written by ABC rewrite] Wheels on the bus (Source: Melon) Tayo the bus [Produced by Wills Garage] James and Giant Apple (Source: Kismet) [Old Macdonald] had a farm [Written by ABC rewrite] Wheels on the (old) bus (Source: Melon) Tayo [the [bus]] [Produced by Wills Garage] James () and Giant[] Apple() (Source: Kismet)
Extraction
Old Macdonald had a farm [Written by ABC rewrite] Wheels on the bus (Source: Melon) Tayo the bus [Produced by Wills Garage] James and Giant Apple (Source: Kismet) [Old Macdonald] had a farm [Written by ABC rewrite] Wheels on the (old) bus (Source: Melon) Tayo [the [bus]] [Produced by Wills Garage] James () and Giant[] Apple() (Source: Kismet)