Forum Discussion
Anthony_Porcano
Nimbostratus
Apr 15, 2007matches_regex and matchclass
Is there any way to apply a regular expression to matchclass? Apologies in advance if I'm missing something obvious here, but my attempts thus far are not working.
if { [ matchclass [HTTP::path] matches_reqex "\/portal\/($::flaggedpaths)\?" ] } {
log local0. "matched [HTTP::path] in flaggedpaths class"
}
Returns:
[invalid option "matches_reqex" must be: contains ends_with equals starts_with] [matches_reqex]
The error seems clear enough. You can only use a subset of the available relational operators with the matchclass command. Am I interpretting this correctly? Is there another way to accomplish pattern matching against a class?
Thanks in advance,
Anthony
- Unfortunately, as you've found out, matchclass is limited to only the operators listed in that error. But, you aren't completely stuck. While it's not as elegant as a single matchclass line, classes are interpreted as TCL lists, so you can use the TCL list commands to loop through the elements and do whatever you want.
when HTTP_REQUEST { foreach path $::flaggedpaths { if { [HTTP::path] starts_with "/portal/$path" } { log local0. "matched [HTTP::path] in flaggedpaths class member '$path'" break } } }
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