added examples to set_to_regex comments

Signed-ff-by: James Lagermann <james.lagermann@corelight.com>
This commit is contained in:
James Lagermann 2020-05-08 12:31:56 -05:00
parent 695457fe44
commit 2c04a56236
No known key found for this signature in database
GPG key ID: 6C22515FCC04F4F2

View file

@ -13,6 +13,13 @@ module GLOBAL;
## string parsing reducing it to a single backslash upon rendering.
##
## Returns: the input pattern with "~~" replaced by OR'd elements of input set.
##
## Examples:
## global r1 = set_to_regex(set("a", "b", "c"), "~~");
## results: r1 = /^?(a|b|c)$?/
##
## global r2 = set_to_regex(set("a.com", "b.com", "c.com"), "\\.(~~)");
## results: r2 = /^?(\.(a\.com|b\.com|c\.com))$?/
function set_to_regex(ss: set[string], pat: string): pattern
{
local i: count = 0;