Forum Discussion
hoolio
Cirrostratus
Nov 03, 2009v10 class matches_glob type functionality?
Hi,
There is a v9 iRule I'm trying to convert and have CMP compatible. The current functionality required using a global TCL list of the format:
set ::global_list [list *uri_token1 /uri_token2* etc]
I was then looping through the list using string match for each list element against the requested URI.
I'd like to implement this kind of functionality using the v10 class command, but it doesn't look like there is a way to check if a string matches a glob style pattern in the datagroup. The 'class get [-nocase] []' option looks close, but it's searching the class for an element that matches a pattern--not searching a class for a pattern which matches the string.
Are there any thoughts on implementing a command like:
class matches_glob
where the class would have elements of glob style string patterns like *uri/ or /uri*. The starts_with, contains and ends_with functionality doesn't quite work here as I want to be able to use a single datagroup and need to support multiple types of matches.
I can open an RFE case based on any info you might be able to provide.
Thanks,
Aaron
- hoolio
Cirrostratus
I ended up using class element to do this, but it seems like extra work that could be made more efficient (or easier) with a glob_match style option for the class command.Loop through each class line for {set i 0} {$i < [class size my_dgl]} {incr i} { Use scan to parse the two fields from the class scan [class element -name $i my_dgl] {%[^ ]%s} my_pattern my_value Use string match to evaluate the pattern against the string if {[string match -nocase $my_pattern [HTTP::uri]]}{ Found a match log local0. "Matched $my_pattern, using $my_value" break } }
- hoolio
Cirrostratus
Hey Colin,
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