class_match(input_string, operation, pattern_table)
Check if input string satisfies operations with patterns.
Syntax
class_match(input_string, operation, pattern_table);
Arguments
| Name | Description |
|---|---|
|
input_string |
The input string to match against the list. |
|
operation |
Operations that support "ends_with" "starts_with" "contains" "equals" operations. |
|
pattern_table |
A table that lists the strings to match against. |
Events
Applicable in all events.
Example
when HTTP_REQUEST {
url_list = {"/admin", "/api", "/private", "/secure"}
url = HTTP:uri_get()
status, count, t = class_match(url, "starts_with", url_list)
debug("status %s, count %s\n", status, count)
-- Safe iteration with type checking
if type(t) == "table" then
for k, v in pairs(t) do
debug("index %s, value %s\n", k, v)
end
else
debug("ERROR: Expected table but got: %s\n", type(t))
end
}
This command returns three parameters:
-
status: a boolean indicating whether at least one match was found (true) or not (false).
-
count: an integer representing how many matches were found in the list.
-
t: a table containing the matched indexes and their corresponding values.
Supported Version
FortiADC version 5.2.x and later.