Forum Discussion
Puli
Nimbostratus
Apr 15, 2011matching numbers patter in a url
I need to match below patter in a url and re-direct traffic.
http://www.abc.com/temp/2011/12/temp.html
Am using below code
if { [string match {*/*[0-9]*/*[0-9]*/* } [HTTP::uri] } {
user pool pool1
}
when run config sync to peer, i get an error saying invalid argument.
if i escape the special characters like
{\*\/\*[0-9]\*\/\*[0-9]\*\/\*} config sync run sucessfully but the url patter does not match.
Any ideas , am ok not using string match if there's a better alternative.
thanks.
5 Replies
- hoolio
Cirrostratus
Hi Puli,
Can you try this:
if { [string match "*/*\[0-9\]*/*\[0-9\]*/*" [HTTP::uri] } {
Only the square braces should need to be escaped if you wrap the pattern in double quotes instead of curly braces.
Aaron - Puli
Nimbostratus
thanks aaron,
works perfect ! appreciate it. - Puli
Nimbostratus
Small problem facing with the match.
Its also matching
http://www.abc.com/temp/barton2011/12/temp.html
How can i make it so it only strictly matches number and ignores letter in it ?
thanks. - hoolio
Cirrostratus
Can you provide a few more examples of URIs you do want to match a few that you don't?
Thanks, Aaron - Puli
Nimbostratus
Hi aaron,
i fixed it, i had a wildcard in front that matching all characters followed by numbers. Below is the modified one
From
if { [string match "*/*\[0-9\]*/*\[0-9\]*/*" [HTTP::uri] } {
to
if { [string match "*/\[0-9\]*/*\[0-9\]/*" [HTTP::uri] } {
I had to match only url of specific type
http://www.abc.com/temp/[digits]/[digits]/temp.html
thanks for the support.
Appreciate it.
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