James_Wrubel_48
Jul 03, 2009Nimbostratus
regexp to parse querystring parameters
I am trying to get a list of querystring parameters from the URI. There's an example iRule that does this here:
http://devcentral.f5.com/wiki/default.aspx/iRules/URIInterrogation.html
The relevant code is:
set namevals [split [HTTP::query] "&"]
for {set i 0} {$i < [llength $namevals]} {incr i} {
set params [split [lindex $namevals $i] "="]
set pnum [expr $i+1]
log local0. "Param\[$pnum\]: [lindex $params 0]"
log local0. "Value\[$pnum\]: [URI::query [HTTP::uri] [lindex $params 0]]"
}
}
That code works fine, but it seems like this would be more efficient as a regexp, or even a foreach. Can anyone think of a better way to implement this?