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"
(subject name=\"(?:Biology|chem102)\"[\s\S]+?)\r?\n^topic$|(^topic$\r?\n)
"
gm
Input 1
1
subject name="Biology" value="12th" topic name="system" value="anything" topic subject name="mathematics" value="12th" topic name="system" value="anything" other topics ="anything" value="anything" topic subject name="chem102" value="12th" topic name="system" value="anything" topic subject name="ComputerSc" value="12th" topic name="system" value="anything" other topics ="anything" value="anything" topic
Substitution
\1\2\n
subject name="Biology" value="12th" topic name="system" value="anything" topic subject name="mathematics" value="12th" topic name="system" value="anything" other topics ="anything" value="anything" topic subject name="chem102" value="12th" topic name="system" value="anything" topic subject name="ComputerSc" value="12th" topic name="system" value="anything" other topics ="anything" value="anything" topic