Forum Discussion
David_Noonan_67
Nimbostratus
Oct 08, 2007Syntax for "matches" and "matches_regex"
We've got an iRule that contains the following code. It works fine but I find the repetition offensive.
elseif {[HTTP::uri] contains "fx1"} {
use pool Xyzzy
}
elseif {[HTTP::uri]...
hoolio
Cirrostratus
Oct 09, 2007Deb, thanks for the link to Colin's tips on avoiding conversions...
noonand, you could also use string wildcards to do this and avoid the more expensive regex evaluation. Here's an example using string match:
elseif {[string match {*fx[1-4]*} [HTTP::uri]]} {
pool Xyzzy
}
If you're doing multiple URI tests, it would probably be faster to use a switch statement:
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
{*fx[1-4]*} { pool test_http_200_pool}
}
}
As Deb said, the string should read:
open brace, asterisk, "fx", open square, 1-4, close square, asterisk, close brace
Aaron
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