import re
p = re.compile(r',? ?\bclass="(?![ab]")[^"]+"')
test_str = "class=\"a\", class=\"b\", class=\"ab\", class=\"body\", class=\"etc\"\nclass=\"b\", class=\"ab\", class=\"body\", class=\"etc\", class=\"a\"\nclass=\"b\", class=\"ab\", class=\"body\", class=\"a\", class=\"etc\""
result = re.sub(p, '', test_str)
print(result)
aW1wb3J0IHJlCnAgPSByZS5jb21waWxlKHInLD8gP1xiY2xhc3M9Iig/IVthYl0iKVteIl0rIicpCnRlc3Rfc3RyID0gImNsYXNzPVwiYVwiLCBjbGFzcz1cImJcIiwgY2xhc3M9XCJhYlwiLCBjbGFzcz1cImJvZHlcIiwgY2xhc3M9XCJldGNcIlxuY2xhc3M9XCJiXCIsIGNsYXNzPVwiYWJcIiwgY2xhc3M9XCJib2R5XCIsIGNsYXNzPVwiZXRjXCIsIGNsYXNzPVwiYVwiXG5jbGFzcz1cImJcIiwgY2xhc3M9XCJhYlwiLCBjbGFzcz1cImJvZHlcIiwgY2xhc3M9XCJhXCIsIGNsYXNzPVwiZXRjXCIiCnJlc3VsdCA9IHJlLnN1YihwLCAnJywgdGVzdF9zdHIpCnByaW50KHJlc3VsdCk=