fork download
  1. import re
  2. def repl(match):
  3. chunks = match.group(1).split(".")
  4. if len(chunks) == 2:
  5. return "FLT_{}".format(len(chunks[1]))
  6. else:
  7. return "INT_{}".format(len(chunks[0]))
  8.  
  9. input_string = "高露潔光感白輕悅薄荷牙膏100 79.80"
  10. result = re.sub(r'[-+]?([0-9]*\.?[0-9]+)(?:[eE][-+]?[0-9]+)?',repl,input_string)
  11. print(result)
  12.  
  13.  
  14.  
  15.  
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
高露潔光感白輕悅薄荷牙膏INT_3   FLT_2