fork download
  1. import re
  2.  
  3.  
  4. r = re.compile(r'(hello|world)')
  5.  
  6.  
  7. string = 'hello world the World!!'
  8.  
  9. print(re.sub(r, r'fuck.\1', string))
  10.  
  11.  
Success #stdin #stdout 0.02s 8736KB
stdin
Standard input is empty
stdout
fuck.hello fuck.world the World!!