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 URL inspection!"
}
default {
reject
}
}
[/CODE]
I believe this should match the following URI: "/first/url/files/1000000"
However, it is also matching a URI like this: "/first/url/files/1000000000000000000000000000000000000"
Any ideas on this one?
2 Replies
- Kevin_Stewart
Employee
I 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. - Brian_69413
Nimbostratus
Thanks!
That was it. Still surprised that it would continue matching indefinitely, but there you have it.
Not sure why my code blocks look all a mess with HTML...
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