fork download
  1. import re
  2.  
  3. pattern = r"(,\s*)[^,]*\sAS\b\s*"
  4. s = ("Select customer_name, customer_type, COUNT(*) AS volume\\nFROM table\\nGROUP BY customer_name, customer_type\\nORDER BY volume DESC\\nLIMIT 10\n")
  5.  
  6. print(re.sub(pattern, r"\1", s))
  7.  
Success #stdin #stdout 0.03s 9500KB
stdin
Standard input is empty
stdout
Select customer_name, customer_type, volume\nFROM table\nGROUP BY customer_name, customer_type\nORDER BY volume DESC\nLIMIT 10