fork(1) download
  1. import re
  2.  
  3. s = "Hi how are you? \nI %am %fine.\nThanks %and %you"
  4. result = re.sub(r"\B%(\w+)", r"[\1]", s)
  5. print(result)
Success #stdin #stdout 0.01s 27744KB
stdin
Standard input is empty
stdout
Hi how are you? 
I [am] [fine].
Thanks [and] [you]