Forum Discussion
kpiti_52215
Nimbostratus
Jan 29, 2013lsearch nocase bug or what?
I wanted to use case insensitive list search but I got an error back. Try this proof-of-concept iRule:
when CLIENT_ACCEPTED {
TCP::collect
}
when CLIENT_DATA {
set list [split [TCP::payload] foo]
if { [lsearch -all -nocase $list bar] >= 0 } {
log local0. "match"
}
}
What I get back is:
01070151:3: Rule [/Common/TestLsearch] error:
line 6: [invalid switch: "-nocase"] [-nocase]
Apart from TCL lsearch specs, this example is even mentioned in Colin's iRules guide Case Insensitive Comparisons
lsearch -all -nocase {a b c a b c} C
I'm running 11.1.0 for reference..
Is this a bug or is there some deeper reason for this?
Jure
3 Replies
- hoolio
Cirrostratus
Hi Jure,
iRules are based on 8.4 Tcl. The -nocase flag was added to lsearch in 8.5:
http://www.tcl.tk/man/tcl8.4/TclCmd/lsearch.htm
http://www.tcl.tk/man/tcl8.5/TclCmd/lsearch.htm
Can you set the list you're searching and the search term in lowercase?
set list [split [string tolower [TCP::payload]] foo]
if { [lsearch -all -nocase $list bar] >= 0 } {
Aaron - kpiti_52215
Nimbostratus
Thanks Aaron,
that explains it. I will do a workaround with a lowercase copy of the payload and doing changes on the real payload.
I guess someone should notify Colin about this as well =)
Jure - kpiti_52215
Nimbostratus
Ah, I see we've both done 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
