strings.starts_with

Supported in:
strings.starts_with(value, suffix)

Description

Function takes two strings (value, suffix). Returns true if the suffix is non-empty and at start-of-value.

Param data types

STRING, STRING

Return type

BOOL

Code samples

The following code samples illustrate some of the ways you might use the strings.starts_with function.

Example: returns true

Returns true when the prefix is found at start-of-value.

strings.starts_with(target.hostname, "www") = true
Example: returns false

Returns false when the prefix isn't at start-of-value.

strings.starts_with(target.hostname, "www") = false
Example: returns true when identical

Returns true when prefix and value are identical.

target.hostname != "example.com"
strings.starts_with("str", "str") = true
Example: returns false when suffix empty

Returns false when prefix is an empty string.

target.hostname != "example.com"
strings.starts_with("", "str") = false
Example: returns false when value empty

Returns false when value is an empty string.

target.hostname != "example.com"
strings.starts_with("str", "") = false
Example: returns false when prefix and value are empty

Returns false when prefix and value are empty strings.

target.hostname != "example.com"
strings.starts_with("", "") = false