fork download
  1. import re
  2. mystring = '2 apple trees yield 4 apples'
  3. by = 2
  4. print(re.sub(r'\d+', lambda x: str(int(x.group())*by), mystring))
Success #stdin #stdout 0s 23352KB
stdin
Standard input is empty
stdout
4 apple trees yield 8 apples