Skip to main content

Functions: String

Kahuna provides the following string manipulation functions, allowing you to work efficiently with text values within your scripts:

FunctionDescriptionExample
len(str)Returns the length of the string strlen("hello")5
lower(str)Converts str to lowercaselower("HELLO")"hello"
upper(str)Converts str to uppercaseupper("hello")"HELLO"
trim(str)Removes leading and trailing whitespace from strtrim(" hello ")"hello"
startsWith(str, prefix)Returns true if str starts with the given prefixstartsWith("abc123", "abc")true
endsWith(str, suffix)Returns true if str ends with the given suffixendsWith("file.txt", ".txt")true
contains(str, substr)Returns true if substr is found within strcontains("hello world", "world")true
replace(str, from, to)Replaces all occurrences of from with to in strreplace("a-b-c", "-", "_")"a_b_c"
split(str, delimiter)Splits str into an array using delimitersplit("a,b,c", ",")["a", "b", "c"]
join(array, delimiter)Joins array elements into a string separated by delimiterjoin(["a", "b"], "-")"a-b"
substring(str, start, end)Returns a substring from start to end (exclusive)substring("abcdef", 1, 4)"bcd"

These functions are useful for formatting values, validating inputs, parsing data, and handling dynamic key names in Kahuna Scripts.