Hi Shuki,
the comparison by match_regex works exactly the way you described it.
Its probably just the pattern, which makes it fail.
Using your example the following iRule returns the expected result:
set RegexStr "\["
set Body [HTTP::payload] ; >>> [11,222,333,4444]
set Body [string range $Body 1 end-1]
set Body [string map {"," " "} $Body]
set ItemCount [llength $Body]
for {set x 0} {$x < $ItemCount} {incr x} {
set Item [lindex $Body $x]
set ItemLength [string length $Item]
append RegexStr "(\\d{$ItemLength}),"
}
replacing the trailing comma by a closing bracket
regsub {,$} $RegexStr "\]" RegexStr
regex match
if { [HTTP::payload] matches_regex $RegexStr } { log "[HTTP::payload] matching regex ($RegexStr)" }
Sending a request by using cURL as follows results in the log message shown below:
curl -v 'http://10.131.131.111/test' --data '[11,222,3333,44444]'
: [11,222,3333,44444] matching regex (\[(\d{2}),(\d{3}),(\d{4}),(\d{5})])
Thanks, Stephan