Skip to main content
Version: 8.5

String functions

substring(string, start position)

Returns a substring of the given value starting at start position.

Function signature

substring(string: string, start position: number): string

The start position starts at the index 1. The last position is -1.

Examples

substring("foobar", 3)
// "obar"

substring("foobar", -2)
// "ar"

substring(string, start position, length)

Returns a substring of the given value, starting at start position with the given length. If length is greater than the remaining characters of the value, it returns all characters from start position until the end.

Function signature

substring(string: string, start position: number, length: number): string

The start position starts at the index 1. The last position is -1.

Examples

substring("foobar", 3, 3)
// "oba"

substring("foobar", -3, 2)
// "ba"

substring("foobar", 3, 10)
// "obar"

string length(string)

Returns the number of characters in the given value.

Function signature

string length(string: string): number

Examples

string length("foo")
// 3

upper case(string)

Returns the given value with all characters are uppercase.

Function signature

upper case(string: string): string

Examples

upper case("aBc4")
// "ABC4"

lower case(string)

Returns the given value with all characters are lowercase.

Function signature

lower case(string: string): string

Examples

lower case("aBc4")
// "abc4"

substring before(string, match)

Returns a substring of the given value that contains all characters before match.

Function signature

substring before(string: string, match: string): string

Examples

substring before("foobar", "bar")
// "foo"

substring after(string, match)

Returns a substring of the given value that contains all characters after match.

Function signature

substring after(string: string, match: string): string

Examples

substring after("foobar", "ob")
// "ar"

contains(string, match)

Returns true if the given value contains the substring match. Otherwise, returns false.

Function signature

contains(string: string, match: string): boolean

Examples

contains("foobar", "of")
// false

starts with(string, match)

Returns true if the given value starts with the substring match. Otherwise, returns false.

Function signature

starts with(string: string, match: string): boolean

Examples

starts with("foobar", "fo")
// true

ends with(string, match)

Returns true if the given value ends with the substring match. Otherwise, returns false.

Function signature

ends with(string: string, match: string): boolean

Examples

ends with("foobar", "r")
// true

matches(input, pattern)

Returns true if the given value matches the pattern. Otherwise, returns false.

Function signature

matches(input: string, pattern: string): boolean

The pattern is a string that contains a regular expression.

Examples

matches("foobar", "^fo*bar")
// true

matches(input, pattern, flags)

Returns true if the given value matches the pattern. Otherwise, returns false.

Function signature

matches(input: string, pattern: string, flags: string): boolean

The pattern is a string that contains a regular expression.

The flags can contain one or more of the following characters:

  • s (dot-all)
  • m (multi-line)
  • i (case insensitive)
  • x (comments)

Examples

matches("FooBar", "foo", "i")
// true

replace(input, pattern, replacement)

Returns the resulting string after replacing all occurrences of pattern with replacement.

Function signature

replace(input: string, pattern: string, replacement: string): string

The pattern is a string that contains a regular expression.

The replacement can access the match groups by using $ and the number of the group, for example, $1 to access the first group.

Examples

replace("abcd", "(ab)|(a)", "[1=$1][2=$2]")
// "[1=ab][2=]cd"

replace("0123456789", "(\d{3})(\d{3})(\d{4})", "($1) $2-$3")
// "(012) 345-6789"

replace(input, pattern, replacement, flags)

Returns the resulting string after replacing all occurrences of pattern with replacement.

Function signature

replace(input: string, pattern: string, replacement: string, flags: string): string

The pattern is a string that contains a regular expression.

The replacement can access the match groups by using $ and the number of the group, for example, $1 to access the first group.

The flags can contain one or more of the following characters:

  • s (dot-all)
  • m (multi-line)
  • i (case insensitive)
  • x (comments)

Examples

replace("How do you feel?", "Feel", "FEEL", "i")
// "How do you FEEL?"

split(string, delimiter)

Splits the given value into a list of substrings, breaking at each occurrence of the delimiter pattern.

Function signature

split(string: string, delimiter: string): list<string>

The delimiter is a string that contains a regular expression.

Examples

split("John Doe", "\s" )
// ["John", "Doe"]

split("a;b;c;;", ";")
// ["a", "b", "c", "", ""]

extract(string, pattern)

Camunda Extension

Returns all matches of the pattern in the given string. Returns an empty list if the pattern doesn't match.

Function signature

extract(string: string, pattern: string): list<string>

The pattern is a string that contains a regular expression.

Examples

extract("references are 1234, 1256, 1378", "12[0-9]*")
// ["1234","1256"]