fork download
  1. import re
  2.  
  3. pattern = r"^(.*?\[br]).+?(?=\[\*.*?](?<!].)(?!])|$)"
  4.  
  5. s = ("[[拱|{{{#!html}}}]][br]팔짱낄 공''':'''\n"
  6. "[[顆|{{{#!html}}}]][br]낟알 과'''-'''[* some annotation that may include quote marks(', \") and brackets(\"(\", \")\", \"[[\", \"]]\").]\n"
  7. "[[廓|{{{#!html}}}]][br]둘레 곽[br]클 확[* another annotation.][* another annotation.]")
  8.  
  9. subst = "$1AAAA"
  10. result = re.sub(pattern, r"\1AAAA", s, 0, re.MULTILINE)
  11. print(result)
Success #stdin #stdout 0.02s 9616KB
stdin
Standard input is empty
stdout
[[拱|{{{#!html}}}]][br]AAAA
[[顆|{{{#!html}}}]][br]AAAA[* some annotation that may include quote marks(', ") and brackets("(", ")", "[[", "]]").]
[[廓|{{{#!html}}}]][br]AAAA[* another annotation.][* another annotation.]