base/utils/strings.zeek

Functions to assist with small string analysis and manipulation that can be implemented as Zeek functions and don’t need to be implemented as built-in functions.

Summary

Functions

cut_tail: function

Cut a number of characters from the end of the given string.

is_string_binary: function

Returns true if the given string is at least 25% composed of 8-bit characters.

join_string_set: function

Join a set of strings together, with elements delimited by a constant string.

string_escape: function

Given a string, returns an escaped version.

Detailed Interface

Functions

cut_tail
Type

function (s: string, tail_len: count) : string

Cut a number of characters from the end of the given string.

S

a string to trim.

Tail_len

the number of characters to remove from the end of the string.

Returns

the given string with tail_len characters removed from the end.

is_string_binary
Type

function (s: string) : bool

Returns true if the given string is at least 25% composed of 8-bit characters.

join_string_set
Type

function (ss: set [string], j: string) : string

Join a set of strings together, with elements delimited by a constant string.

Ss

a set of strings to join.

J

the string used to join set elements.

Returns

a string composed of all elements of the set, delimited by the joining string.

string_escape
Type

function (s: string, chars: string) : string

Given a string, returns an escaped version.

S

a string to escape.

Chars

a string containing all the characters that need to be escaped.

Returns

a string with all occurrences of any character in chars escaped using \, and any literal \ characters likewise escaped.