Forum Discussion
Mike_S_64601
Nimbostratus
Apr 11, 2007Problem using regexp - syntax error on [
First time attempting to use a regexp in an irule; running into a syntax error in this script:
when HTTP_REQUEST {
if { [HTTP::uri] matches_regex "^\/[a-zA-Z][a-zA-Z]\/" } {
pool pool1
} else {
pool pool2
}
}
I get a syntax error on the expression:
line 2: [undefined procedure: a-zA-Z] [a-zA-Z]
Basically I want to use pool1 if the request path starts with a two-letter directory, and use pool2 if the path starts with anything else.
Is this the best way? What am I doing wrong in the matches_regex syntax?
Thanks for any assistance!
- TCL uses brackets to denote procedure execution. You'll need to escape the brackets.
when HTTP_REQUEST { if { [HTTP::uri] matches_regex "^\/\[a-zA-Z\]\[a-zA-Z\]\/" } { pool pool1 } else { pool pool2 } }
- hoolio
Cirrostratus
Else, I think you could use the wildcards (? or [chars]) available in TCL's string match command for a lighter weight comparison: - Mike_S_64601
Nimbostratus
Excellent - thank you both very much!
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects