If you're using values that contain no spaces then you can just use space as the separator and gain direct list functions:
when RULE_INIT {
set lookupname [class lookup 192.168.1.1 test]
log local0. "lookupname $lookupname"
foreach name $lookupname {
log local0. "name $name"
}
log local0. "james_a [lsearch $lookupname "james_a"]"
log local0. "john_b [lsearch $lookupname "john_b"]"
log local0. "george_k [lsearch $lookupname "george_k"]"
log local0. "james_a [lsearch [class lookup 192.168.1.1 test] "james_a"]"
if { [expr {[lsearch [class lookup 192.168.1.1 test] "james_a"] + 1}] } {
log local0. "james_a exists"
} else {
log local0. "james_a does not exist"
}
if { [expr {[lsearch [class lookup 192.168.1.1 test] "george_k"] + 1}] } {
log local0. "george_k exists"
} else {
log local0. "george_k does not exist"
}
}
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : lookupname james_a john_b fred_c
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : name james_a
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : name john_b
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : name fred_c
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : james_a 0
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : john_b 1
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : george_k -1
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : james_a 0
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : james_a exists
Nov 20 21:20:18 bigip1 info tmm[29813]: Rule /Common/test_r : george_k does not exist