d2_21508
Oct 06, 2015Nimbostratus
is it possible to use regex within switch block?
Hello!
Is it possible to use regular expressions within switch block? My scenario:
- a.domain.com
- a.domain.net
So different TLDs. Now I want to write iRule that will handle both 'com' and 'net', but I can't figure this out and instead I have to use following syntax:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"a.domain.com" {
pool some_pool_a
}
"a.domain.net" {
pool some_pool_a
}
"b.domain.com" {
pool some_pool_b
}
"b.domain.net" {
pool some_pool_b
}
}
}
I would like to rewrite this iRule to something like this:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"a.domain.[com|net]" {
pool some_pool_a
}
"b.domain.[com|net]" {
pool some_pool_b
}
}
}
but it seems to be not working. Do you guys have any good idea how to fix it? BTW - I'm using v11.6 of BIG IP software.