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.

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.

Parameters
  • 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.

string_escape
Type

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

Given a string, returns an escaped version.

Parameters
  • 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.