class_search(pattern_table, operation, input_string)
Searches through a list of strings to find elements that match the given pattern or criteria using specified matching methods.
Syntax
class_search(pattern_table, operation, input_string);
Arguments
| Name | Description |
|---|---|
|
pattern_table |
A table that lists the strings to search through. |
|
operation |
Operations that support "ends_with" "starts_with" "contains" "equals" operations. |
|
input_string |
The pattern or string to match against the list elements. |
Events
Applicable in all events.
Example
when HTTP_REQUEST {
status, count, t = class_search(url_list, "starts_with", url); --or "ends_with", "equals", "contains"
for k, v in pairs(t) do
debug("index %s, value %s\n", k, v);
end
}
This command returns three parameters:
-
status: a boolean indicating whether at least one match was found (true) or not (false).
-
count: an integer specifying how many elements in the list match the pattern.
-
t: a table containing the matched list elements and their corresponding indexes.
Supported Version
FortiADC version 5.2.x and later.