fork download
  1. import re
  2. p = re.compile(r' \$?::(?=(?:(?!\$?::)[^\]])*\])')
  3. test_str = "when HTTP_REQUEST {\n if { [matchclass $::USERAGENT contains $::XYZ ] or [matchclass $::USERAGENT contains $::ABC ] } { drop }\n if { [matchclass $USERAGENT contains ::TEST ] } { drop }\n if { [ matchclass $::useragent contains $::TEST ] } { drop }\n return \n}\n\n"
  4. result = p.sub(" ", test_str)
  5. print(result)
Success #stdin #stdout 0.02s 9016KB
stdin
Standard input is empty
stdout
when HTTP_REQUEST {
  if { [matchclass  $::USERAGENT  contains XYZ ] or [matchclass  $::USERAGENT  contains ABC ] } { drop }
  if { [matchclass  $USERAGENT    contains TEST ] } { drop }
  if { [ matchclass $::useragent    contains TEST ] } { drop }
  return 
}