fork download
  1. import re
  2. text = "keyword\n#keyword\nsome keyword\n[[keyword]] keyword"
  3. print( re.sub(r'\b(?<!\[\[)(?<!#)keyword\b', r'[[\g<0>]]', text) )
Success #stdin #stdout 0.02s 9664KB
stdin
Standard input is empty
stdout
[[keyword]]
#keyword
some [[keyword]]
[[keyword]] [[keyword]]