fork download
  1. import re
  2.  
  3. regex = r"\bwhere(?:(?:(?!where)[^][])*\[[^][]*])+\s*"
  4. txt = ("where this condition and [this = 1] group by 1,2,3\n"
  5. "where that and that do that where [this = 1] and [that = 1] group by 1,2,3")
  6. result = re.sub(regex, "", txt)
  7.  
  8. print (result)
Success #stdin #stdout 0.03s 9508KB
stdin
Standard input is empty
stdout
group by 1,2,3
where that and that do that group by 1,2,3