Forum Discussion
TMaCEvans_92750
Nimbostratus
15 years agoconverting regex to irule
i'm wondering if its possible to carry out the below rules below in an irule?
article page: match url="^([A-Za-z\-]+)/([A-Za-z\-0-9.]+)/([0-9]+)(/)" url="Full_Article.aspx?art_id={R:3}"
category archive page: match url="^Archive/([A-Za-z\-0-9.]+)/([0-9]+)/([0-9]+)(/)" url="archive.aspx?cat_id={R:2}&pg={R:3}
date archive page: match url="^Archive/([0-9]+)\-([0-9]+)/([0-9]+)(/)" url="archive.aspx?mon={R:1}&yr={R:2}&pg={R:3}
news homepage: match url="^/" url="Home.aspx"
rss page: match url="^Rss" url="RSS.aspx"
4 Replies
- hoolio
Cirrostratus
Can you give a few sample strings for each case? We should be able to adapt this to iRule code using scan or string commands instead of regexes for better performance.
http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/1086476/iRules-10118Revisiting-the-TCL-Scan-Command.aspx
http://www.tcl.tk/man/tcl8.4/TclCmd/scan.htm
Aaron - Colin_Walker_12Historic F5 AccountThe answer is definitely yes. As Aaron indicated, using something other than regular expressions will likely be vastly superior performance wise. Regular expressions are powerful and when necessary iRules can certainly allow you to use them, but we tend to recommend them as a last option.
Colin - TMaCEvans_92750
Nimbostratus
I've managed to get all the rules working accept for this one
category archive page: match url="^Archive/([A-Za-z\-0-9.]+)/([0-9]+)/([0-9]+)(/)" url="archive.aspx?cat_id={R:2}&pg={R:3}
} elseif { [scan [HTTP::uri] {/Archive/%[A-Za-z\-0-9.]/%[0-9]/%[0-9]} s1 s2 s3] == 3 } {
scan [HTTP::uri] {/Archive/%[A-Za-z\-0-9.]/%[0-9]/%[0-9]} s1 s2 s3
log -noname local0. "$s1 $s2 $s3"
HTTP::respond 301 Location "http://[HTTP::host]/archive.aspx?cat_id=$s2&pg=$s3"
I'm not sure how to simulate the (+) as when i try add it in i get the following error on the f5
Aug 25 11:15:12 local/tmm err tmm[5040]: 01220001:3: TCL error: NewsRegex - bad scan conversion character "(" while executing "scan [HTTP::uri] {/Archive/%([A-Za-z\-0-9]+)/%([0-9]+)/%[0-9]} s1 s2 s3" - TMaCEvans_92750
Nimbostratus
double post
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