Best Practice: Regex vs number of if/else
I previously had a rule that had:
if {
$login == 1 &&
([string first "OP=help" [HTTP::header "location"]] == -1) &&
([string first "OP=token_login" [HTTP::header "location"]] == -1) &&
([string first "OP=error" [HTTP::header "location"]] == -1) &&
([string first "ERR_CODE=0x13212077 " [HTTP::header "location"]] == -1) &&
([string first "ERR_CODE=0x132120c8" [HTTP::header "location"]] == -1) &&
([string first "OP=acct_locked" [HTTP::header "location"]] == -1) } {
} {
..do something...
}
I then thought that this was a bit inefficient as you would have to traverse each condition before "doing something". I thought i would change this to a regex:
if { $login == 1 &&
([regexp "OP=help|OP=token_login|OP=error|ERR_CODE=0x13212077|ERR_CODE=0x132120c8|OP=acct_locked" [HTTP::header "location"]] == 0)
} {
..do something...
}
But reading some solutions on AskF5 and the iRule 101 Blogs it seems that F5 generally recommend avoiding regex for simple cases.
So I thought i would ask the masses....any experience or any advice on what is the best approach?
Thanks in advance,
NJ