Forum Discussion
Brian_69413
Nimbostratus
Sep 20, 2012regex issues
I have the following iRule switch statement:
[CODE]
switch -regexp [string tolower [HTTP::uri]] {
"/first/url/files/[1-9][\d]{0,6}" {
log local0. "You passed UR...
Kevin_Stewart
Employee
Sep 21, 2012I believe the problem is that you're not specifically evaluating to the end of the string. You need to use the "$" character at the end to indicate "to end of string".
when HTTP_REQUEST {
switch -regexp [string tolower [HTTP::uri]] {
"/first/url/files/[0-9]{0,7}$" {
log local0. "You passed URL inspection!"
}
default {
reject
log local0. "rejected"
}
}
This will catch any numeric value from nothing to 1000000. Change the evaluation to {1,7} if you want to make sure there's at least one digit in the string.
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