» Import: strings

The strings import exposes common string operations.

» strings.has_prefix(s, prefix)

Returns true if s starts with prefix.

strings.has_prefix("billing-id", "billing-") // true
strings.has_prefix("bill-id", "billing-")    // false

» strings.has_suffix(s, suffix)

Returns true if s ends with suffix.

strings.has_suffix("billing-id", "id")   // true
strings.has_suffix("billing-name", "id") // false

» strings.trim_prefix(s, prefix)

Trim the prefix from the string s. If the string doesn't have the prefix, then the string is returned unmodified.

strings.trim_prefix("billing-id", "billing-")   // "id"
strings.trim_prefix("bill-id",    "billing-")   // "bill-id"

» strings.trim_suffix(s, suffix)

Trim the suffix from the string s. If the string doesn't have the suffix, then the string is returned unmodified.

strings.trim_suffix("billing-id", "-id")    // "billing"
strings.trim_suffix("bill-id",    "-foo")   // "bill-id"

» strings.to_lower(s)

Lowercase the string s.

strings.to_lower("FoO") // "foo"

» strings.to_upper(s)

Uppercase the string s.

strings.to_upper("FoO") // "FOO"