Forum Discussion
Robert_47833
Altostratus
May 09, 2011confused by match_regx
Hi,can someone help?
when HTTP_REQUEST
{ default vars set in most iRules written by StubHub
set host [HTTP::host]
set uri [HTTP::path]
set subdomain1 "static"
set...
hoolio
Cirrostratus
May 10, 2011Actually, the issue seems to be that the backslash needs to be escaped. This is necessary as the regex is wrapped in double quotes. If you didn't have any variables that needed to be interpreted, you could wrap the regex in curly braces.
So this code correctly logs no match:
set host "sjj-cache28.dddstatic.com"
set subdomain1 "static"
set subdomain2 "s"
if { $host matches_regex "^(?:$subdomain1|$subdomain2)\\." }{
log local0. "matched host check for $subdomain2 on $host"
} else {
log local0. "no match on host check for $subdomain2 on $host"
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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