fork download
  1. import re
  2.  
  3. some_text = 'xxxxxxx@yyyyyyyyy@zzzzzzzzz@'
  4. substitutions = ['ONE', 'TWO', 'THREE']
  5. pattern = re.compile('@')
  6. x = pattern.sub(lambda i: substitutions.pop(0), some_text)
  7.  
  8. print x
Success #stdin #stdout 0.03s 6680KB
stdin
Standard input is empty
stdout
xxxxxxxONEyyyyyyyyyTWOzzzzzzzzzTHREE