Skip to main content

String Functions

Match Functions

  • startsWith(x, term): Checks if the string x starts with the passed term. Matches are case-sensitive.

  • endsWith(x, term): Checks if the string x ends with the passed term. Matches are case-sensitive.

  • contains(x, term): Checks if the string x contains the passed term anywhere. Matches are case-sensitive.

  • match(x, pattern) or match(x, pattern, group): Checks if string x contains a match for given pattern and returns the match. If a group number is provided, only the matching subgroup will be returned. If no match is found, empty string is returned. See pattern-match for a variable operation that contains additional matching capabilities.

  • test(x, pattern): Checks if string x contains the given pattern. See pattern-test for a variable operation that contains additional capabilities.

Modify Functions

  • replace(x, pattern, replacement): Checks string x for all substrings matching the given pattern and replaces them with the given replacement. Supports backreferences like $1, $2, …. See pattern-replace for a variable operation that contains additional capabilities.

  • lpad(x, length, c): Pads a string x to the left with the character c, so that the padded string has length characters.

  • rpad(x, length, c): Pads a string x to the right with the character c, so that the padded string has length characters.

Misc Functions

  • size(x): Gets the length of string x. If x is an array, gets the number of elements in the array.

Examples

startsWith(msg, 'EX')
endsWith(msg, 'EX')
contains(msg, 'error') 
match(msg, 'M\d+'')
match(msg, 'M(\d+)'', 1)
test(msg, 'M60(\s|$)')
replace(msg, 'M(\d+)', '$1')