import re
regex = re.compile(r"(^[#>]|(?!^)\G).*?\K(?:\[\[|]])", flags=re.MULTILINE)
test_str = ("## [[zoom]] _[v]_\n\n"
">[[move]] | [[very]] | [[quickly]]\n\n"
"__Synonyms__: [[buzz]] | [[dart]] | [[dash]] | [[dive]] | [[flash]] | [[fly]] | [[hum]] | [[hurtle]] | outstrip | [[rip]] | [[rocket]] | [[rush]] | [[shoot]] | [[shoot]] up | [[skyrocket]] | [[speed]] | [[streak]] | [[surge]] | [[tear]] | [[whirl]] | [[whiz]] | [[zip]]\n\n"
"__Concepts__: [[ACTIONS - MOTION#move oneself quickly (150)\\|move oneself quickly]] \n\n"
"__Antonyms__: decelerate, [[slow]]\n\n"
"## [[zip]] _[n]_\n\n"
">[[enthusiasm]], [[energy]]\n\n"
"__Synonyms__: brio | [[drive]] | [[get]]-upand-[[go]] | [[go]] | [[gusto]] | [[life]] | liveliness | [[oomph]] | [[pep]] | [[pizzazz]] | [[punch]] | [[sparkle]] | [[spirit]] | [[verve]] | [[vigor]] | vim | [[vitality]] | [[zest]] | [[zing]]\n\n"
"__Concepts__: [[LIFE FORMS - GENERAL CHARACTERISTICS#personality (411)\\|personality]], [[STATES - ABSTRACT#behavior (633)\\|behavior]] \n\n"
"__Antonyms__: [[apathy]], enervation, [[idleness]], [[laziness]], [[lethargy]]\n"
" \n"
"## [[zip]] _[v]_\n\n"
">[[move]] | [[about]] | [[quickly]]\n\n"
"__Synonyms__: [[bustle]] | [[dash]] | [[flash]] | [[fly]] | [[hasten]] | [[hurry]] | [[run]] | [[rush]] | [[shoot]] | [[speed]] | [[tear]] | waltz | [[whisk]] | [[whiz]] | [[zoom]]\n\n"
"__Concepts__: [[ACTIONS - MOTION#move oneself quickly (150)\\|move oneself quickly]] \n\n"
"__Antonyms__: decelerate, [[slow]]")
subst = ""
result = regex.sub(subst, test_str)
if result:
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html