fork download
  1. import re
  2. p = re.compile(r',? ?\bclass="(?![ab]")[^"]+"')
  3. 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\""
  4. result = re.sub(p, '', test_str)
  5. print(result)
Success #stdin #stdout 0.01s 7692KB
stdin
Standard input is empty
stdout
class="a", class="b"
class="b", class="a"
class="b", class="a"