Forum Discussion
RahulK_74703
Nimbostratus
Sep 24, 2009Q ? Rewrite rule
I'm trying to write a rule that will hit URI like:
/pages/auto-01111.html
/pages/healthy-living-01234.html
{[scan [HTTP::uri] {/pages/%[a-zA-Z0-9:]-%[0-9:].html} a b] == 2}
{ HTTP::uri "/pages/$a.aspx?ZipCode=$b" }
It's not working if there is two "-" in the URI, like "/pages/healthy-living-01234.html".
If add "{/pages/%[a-zA-Z0-9:\-]-%[0-9:].html} a b] == 2}", it doesn't hit.
Could you help ?
thanks
1 Reply
- hoolio
Cirrostratus
It's the exact scan command you were trying, but what about this:
% scan /pages/auto-01111.html {/pages/%[^0-9]%[0-9:].html}
auto- 01111
% scan /pages/healthy-living-01234.html {/pages/%[^0-9]%[0-9:].html}
healthy-living- 01234
You could then use string range to trim off the last hyphen from the first match:
% scan /pages/healthy-living-01234.html {/pages/%[^0-9]%[0-9:].html} a b
2
% set a [string range $a 0 end-1]
healthy-living
% echo "$a $b"
"healthy-living 01234"
Aaron
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