fork download
  1. import re
  2.  
  3. string = "aaaaa, bbb ,cccc, hhhh, fff,t";
  4.  
  5. def repl(match):
  6. return match.group(1).ljust(10)
  7.  
  8. rx = r'(\w+)(\s*,|$)'
  9. string = re.sub(rx, repl, string)
  10. print string
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
aaaaa      bbb       cccc       hhhh       fff       t