fork(1) download
  1. import re
  2.  
  3. def replace(e):
  4. return e
  5.  
  6. s = 'hi how are you today 23:i ok im good 1:e'
  7. rx = r'(?<!\S)(\d{1,2}:[ie])(?!\S)|\S+'
  8. print(re.sub(rx, lambda x: x.group(1) if x.group(1) else replace(x.group().lower()), s))
Success #stdin #stdout 0.02s 27744KB
stdin
Standard input is empty
stdout
hi how are you today 23:i ok im good 1:e