Forum Discussion
Robert_47833
Altostratus
Apr 19, 2011question about :matches_regex
Hi,met trouble in matches_regex now
difference in expressions below
set uri [HTTP::path]
{$uri matches_regex "^/(cjj)"} { pool cjj01-BRO }
{$uri matches_regex "^/cjj"} { pool cjj01-WSE }
If I wanna visit http://10.1.1.1/cjjtext&hh1 so the &uri should be cjjtext&hh1
1:Will this uri match ^/cjj or another one
2:which uri will match "^/(cjj)" ,actually I don't understand the () here
Can someone help me in this issue
8 Replies
Sort By
- hoolio
Cirrostratus
Hi,switch -glob [HTTP::path] { "/(cjj)*" { pool cjj01-BRO } "/cjj*" { pool cjj01-WSE } }
- Robert_47833
Altostratus
Thanks for your answer - hoolio
Cirrostratus
Normally you could use a capturing group defined by the expression in the parentheses to capture the matched characters. Here's an example: - Robert_47833
Altostratus
oh - hoolio
Cirrostratus
That's it exactly. I'd still suggest using a switch statement instead of a regex. - Robert_47833
Altostratus
we will ,haha - Robert_47833
Altostratus
it is so late in USA,you are still up - hoolio
Cirrostratus
matches_regex will cost more in CPU than a string function like switch.
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