Forum Discussion
Anonymous
Feb 01, 2016how to match "\w" with -glob to avoid using -regexp
Hi team,
I need help with iRule to filter URLs.
I want to match:
/some/path/only_words-XXX or /some/path/only_words-XXXX (and everything below)
XXX and XXXX are numbers (length 3 or 4), "only_w...
Kai_Wilke
MVP
Feb 01, 2016Hi Vova V,
the
switch -glob matching pattern is very limited in its capabilities. Basically this is what it could do...
switch -glob -- [HTTP::uri] {
"/some/path/[A-z]-[0-9]/*" {
This would match /some/path/a-1/file.txt or /some/path/A-2/file.txt or /some/path/_-2/file.txt but not /some/path/bb-22/file.txt
}
"/some/path/[A-z][A-z][A-z]-[0-9][0-9][0-9]/*" {
This would match /some/path/abc-122/file.txt or /some/path/a_b-321/file.txt but not /some/path/a_cd-2234/file.txt
}
"/some/path/*-[0-9][0-9][0-9]/*" - "/some/path/*-[0-9][0-9][0-9][0-9]/*" {
This would match /some/path/a_bc-123/file.txt or /some/path/ab_cd_ef-gh-1234/file.txt or /some/path/1234-1234/file.txt or /some/path/abc/a/b/c/d-123/file.txt but not /some/path/a_b-22/file.txt or /some/path/a_b-222a/file.txt
}
"/some/path/*/*" {
This would match /some/path/aaa/file.txt or /some/path/123/file.txt or /some/path/abc123/file.txt but not /some/path/file.txt or /some/path2/abc_123/file.txt
}
default {
This would match everything else..
}
}
Cheers, Kai
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