fork download
  1. import re
  2. strs = ['1234 foo foo', '19 bar bar', '0 baz baz']
  3. rx = re.compile(r'^(?:(\d{1,2})|(\d+)\d{2})(?!\d)')
  4. for s in strs:
  5. print(rx.sub(lambda x: '100' if x.group(1) else x.group(2)+"00", s))
Success #stdin #stdout 0s 23296KB
stdin
Standard input is empty
stdout
1200 foo foo
100 bar bar
100 baz baz