Forum Discussion

Albert__Tase_70's avatar
Albert__Tase_70
Icon for Nimbostratus rankNimbostratus
Jan 03, 2007

Need help converting form 4 to 9

if (http_host matches_regex "demo.nature.com") {

 

use pool demo

 

}

 

else if (http_host matches_regex "xml.nature.com" or http_host matches_regex "palgravexml.nature.com") {

 

use pool Autonomy

 

}

 

else {

 

discard

 

}

 

1 Reply

  • Stay away from regular expressions if you can at all help it. Using the switch statement with file globbing (-glob) or the starts_with/ends_with/contains operators can cover most of the cases where users use regular expressions. In your case you are just doing a straight string compare so regular expressions are way overkill.

    Here's an example of your rule using the switch statement.

    when HTTP_REQUEST {
      switch -glob [string tolower [HTTP::host]] {
        "demo.nature.com" {
          pool demo
        }
        "xml.nature.com" -
        "palgravexml.nature.com" {
          pool Autonomy
        }
        default {
          discard
        }
      }
    }

    -Joe