Richard_Jones
Jun 22, 2011Nimbostratus
Different results from TCL regexp and iRules regexp
I am working on an iRule that will validate the value of a parameter only contains a-z, 0-9, and / + =. I have created a regexp pattern that works in TCL, but not in an iRule:
TCL:
% regexp {^(?:[a-z0-9/+=]+)$} 1324
1
% regexp {^(?:[a-z0-9/+=]+)$} asdf
1
% regexp {^(?:[a-z0-9/+=]+)$} wqer!
0
% regexp {^(?:[a-z0-9/+=]+)$} asfd/
1
iRule:
log local0. "Val: $decoded_val"
set res [regexp {^(?:[a-z0-9/+=]+)$} $val]
log local0. "Res: $res"
Output:
Rule validate_param : Val: 1324
Rule validate_param : Res: 0
Rule validate_param : Val: asdf
Rule validate_param : Res: 0
Rule validate_param : Val: wqer!
Rule validate_param : Res: 0
Rule validate_param : Val: asfd/
Rule validate_param : Res: 0
The same regexp pattern matches the correct 3 entries when run via tclsh, but doesn't match anything correctly when run through an iRule. Ideas??
I realize that regexp isn't the most efficient, so I'm open to other alternatives as well.
Thanks
Richard