Shuki_griba_304
Feb 10, 2017Nimbostratus
Regexp as string - dynmic
Hello, I need help about Regexp. The [HTTP::payload] at HTTP_REQUEST_DATA is dynamic. i made a procedure that build the regexp. i don't know how to write the "if" Sentence. The procedure:
set RegexStr "["
set Body [HTTP::payload] [210,21,33]
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]
if {$x < $ItemCount} {
append RegexStr "(\d{$ItemLength}),"
}
else {
append RegexStr "(\d{$ItemLength})]"
}
}
The Result of this procedure: $RegexStr = "[(d{3}),(\d{2}),(\d{2})]" ---match the Body
I need solution like this "IF":
if {$Body matches_regex $RegexStr} { log local0. "Matched" }
Thanks