Forum Discussion
Robert_47833
Apr 19, 2011Altostratus
question 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
- hooleylistCirrostratusHi,
switch -glob [HTTP::path] { "/(cjj)*" { pool cjj01-BRO } "/cjj*" { pool cjj01-WSE } }
- Robert_47833AltostratusThanks for your answer
- hooleylistCirrostratusNormally you could use a capturing group defined by the expression in the parentheses to capture the matched characters. Here's an example:
- Robert_47833Altostratusoh
- hooleylistCirrostratusThat's it exactly. I'd still suggest using a switch statement instead of a regex.
- Robert_47833Altostratuswe will ,haha
- Robert_47833Altostratusit is so late in USA,you are still up
- hooleylistCirrostratusmatches_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