# FixUtil Documentation

Back to summary

`import "util/string";`

## Global functions

`function string_append(base: String, s: String)
function string_append(base: String, s: String, start: Integer)
function string_append(base: String, s: String, start: Integer, end: Integer)
`
  Appends a string (or a range, the ending is exclusive) to another string. When the end index is not provided the remainder of the string from given start index is appended.
`function string_insert(base: String, idx: Integer, s: String)
function string_insert(base: String, idx: Integer, s: String, start: Integer)
function string_insert(base: String, idx: Integer, s: String, start: Integer, end: Integer)
`
  Inserts a string (or a range, the ending is exclusive) to another string at given index. When the end index is not provided the remainder of the string from given start index is appended.
`function string_insert_char(s: String, idx: Integer, char: Integer)
`
  Inserts a single character to a string at given index.
`function string_remove(s: String, idx: Integer)
function string_remove(s: String, start: Integer, end: Integer)
`
  Removes portion of a string (either a single character or a range, the ending is exclusive).
`function string_substring(s: String, start: Integer): String
function string_substring(s: String, start: Integer, end: Integer): String
`
  Returns a substring for given range (the ending is exclusive). When no ending index is provided the end of string is used.
`function string_join(array, delim: String): String`
  Returns a string where each element of the array is converted to a string if needed and appended into a new string using a given delimiter.
`function string_split(s: String, char: Integer): String[]
function string_split(s: String, char: Integer, multi: Boolean): String[]
`
  Splits the given string by the specified character. Optionally it can split by multiple count of the character. An empty string results into an empty array.
`function string_starts_with(s: String, match: String): Boolean`
  Returns true when the given string starts with the specified string.
`function string_ends_with(s: String, match: String): Boolean`
  Returns true when the given string ends with the specified string.
`function string_replace_char(s: String, char: Integer, replacement: Integer): String`
  Finds and replaces all characters and returns the result as a new string.
`function string_replace_char_inplace(s: String, char: Integer, replacement: Integer)`
  A variant of the `string_replace_char` function that modifies the string in-place.
`function string_replace_string(s: String, search: String, replacement: Integer): String`
  Finds and replaces all occurences of given string and returns the result as a new string.
`function string_replace_string_inplace(s: String, search: String, replacement: String)`
  A variant of the `string_replace_string` function that modifies the string in-place.
`function string_char(char: Integer): String`
  Returns a new string with a single character.
`function string_to_lower_case(s: String): String`
  Returns a new string where each character is converted into a lower case variant (ASCII only).
`function string_to_upper_case(s: String): String`
  Returns a new string where each character is converted into a upper case variant (ASCII only).
`function string_trim(s: String): String
function string_trim(s: String, is_whitespace_func): String
`
  Trims a whitespace (optionally defined by provided function) from the beginning and ending of the string. The result is returned as a new string.
`function string_trim_inplace(s: String)
function string_trim_inplace(s: String, is_whitespace_func)
`
  Variants of `string_trim` functions that modify the original string in-place.
`function string_pad_left(s: String, len: Integer): String
function string_pad_left(s: String, len: Integer, char: Integer): String
`
  Pads the string from the left to given length using the specified character (or space when not provided). No adjustment is done when the string is bigger. Returns the result as a new string.
`function string_pad_right(s: String, len: Integer): String
function string_pad_right(s: String, len: Integer, char: Integer): String
`
  Pads the string from the right to given length using the specified character (or space when not provided). No adjustment is done when the string is bigger. Returns the result as a new string.
`function string_search_char(s: String, char: Integer): Integer
function string_search_char(s: String, char: Integer, start: Integer): Integer
function string_search_char(s: String, char: Integer, start: Integer, end: Integer): Integer
`
  Searches for given character in a string (optionally within a range, the end is exclusive). Returns the index or -1 when the character is not found.
`function string_rev_search_char(s: String, char: Integer): Integer
function string_rev_search_char(s: String, char: Integer, end: Integer): Integer
function string_rev_search_char(s: String, char: Integer, start: Integer, end: Integer): Integer
`
  Variants of `string_search_char` functions that search from the end.
`function string_search_multi_char(s: String, chars: String): Integer
function string_search_multi_char(s: String, chars: String, start: Integer): Integer
function string_search_multi_char(s: String, chars: String, start: Integer, end: Integer): Integer
`
  Variants of `string_search_char` functions that search multiple characters.
`function string_rev_search_multi_char(s: String, chars: String): Integer
function string_rev_search_multi_char(s: String, chars: String, end: Integer): Integer
function string_rev_search_multi_char(s: String, chars: String, start: Integer, end: Integer): Integer
`
  Variants of `string_search_multi_char` functions that search from the end.
`function string_search_string(s: String, search: String): Integer
function string_search_string(s: String, search: String, start: Integer): Integer
function string_search_string(s: String, search: String, start: Integer, end: Integer): Integer
`
  Searches for given string in a string (optionally within a range, the end is exclusive). Returns the index or -1 when the character is not found.
`function string_rev_search_string(s: String, search: String): Integer
function string_rev_search_string(s: String, search: String, end: Integer): Integer
function string_rev_search_string(s: String, search: String, start: Integer, end: Integer): Integer
`
  Variants of `string_search_string` functions that search from the end.
`function string_contains(s: String, search: String): Boolean`
  Returns whether the string contains a string.
`function string_compare(s1: String, s2: String): Integer`
  Returns negative value when s1 is less than s2, zero when they're equal or positive value when s1 is greater than s2.
`function string_parse_hex_int(s: String): Integer
function string_parse_hex_int(s: String, default_value: Integer): Integer
function string_parse_hex_int(s: String, off: Integer, len: Integer): Integer
function string_parse_hex_int(s: String, off: Integer, len: Integer, default_value: Integer): Integer
`
  Returns the integer representation of the hex string. You can optionally pass a default value to return instead of an error.
`function string_from_hex_int(value: Integer): String
function string_from_hex_int(s: String, value: Integer): String
`
  Return the string representation of the integer value as a hex string. Optionally it can append it into an existing string.