import retext = "keyword\n#keyword\nsome keyword\n[[keyword]] keyword"print( re.sub(r'\b(?<!\[\[)(?<!#)keyword\b', r'[[\g<0>]]', text) )
Standard input is empty
[[keyword]] #keyword some [[keyword]] [[keyword]] [[keyword]]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!