String Expressions

Several convenience functions are available for common String processing situations.

The following table describes the list of functions available for String expressions

Table 1. String Expressions

Type

Expressions

Description

Length

StringLen(str: string): number

Returns the length of the string.

Conditional

  • StringStartsWith(str: string, subStr: string): Boolean Returns True if the string begins with the provided substring; otherwise, it returns False.
  • StringContains(str: string, subStr: string): Boolean Returns True if the substring is contained anywhere in the string; otherwise, it returns False.
  • StringEndsWith(str: string, subStr: string): Boolean Returns True if the string ends with the provided substring; otherwise, it returns False.

Returns the conditional value of the function. True or False.

Building

StringBuilder(...strings): string

Concatenates multiple strings into a single string

Trim

StringTrim(str: string)

Removes all white space characters from the beginning and end of the string.

To Lower Case

StringToLowerCase(str: string)

Converts the entire string to lowercase.

Regular Expressions

  • x ~= y
  • x ~= ^(abc)

These are patterns used to match character combinations in strings. ~= indicates that the string is being compared to a regular expression and will return True if the string matches the expression or False if it does not. Refer to RegEx documentation for pattern descriptions.

Index Of

StringIndexOf(str: string, subStr): Number

Returns the index of subStr in str, or -1 if subStr is not contained in str.

Replace

StringReplace(str: string, replaceStr: string, withStr: string): string

Searches for the value replaceStr in str and replaces it with the value withStr. For example, StringReplace('abcdefg', 'abc', 'xyz') returns the string 'xyzdefg'.

Replace Regular Expression

StringRexExpReplace(str: string, regexp: string, withStr: string, flags?: string): string

Searches for the regular expression represented by regexp in str and replaces it with the value in withStr. The flags can be used to designate options when using the regular expression. Refer to RegEx documentation for more details on using regular expressions.

Return a new string

StringSlice(str: string, start: number, end: number): string

Returns a new string starting at the character provided in the start and ending at the index before the value provided in the end or until the end of the string is reached. For example, StringSlice('abcdefg', 2, 5) returns the string 'cde'. If an end is not provided, the substring continues until the end of str.

Split the existing string

StringSplit(str: string, separator: string): [string]

Splits the existing string into an array of strings based on the provided separator character. For example, StringSplit('a+b+c', '+') returns the array ['a', 'b', 'c'].

Match the regular expression

StringMatch(str: string, regexp: string, flags: string): [string]

Searches for the regular expression provided in regexp in str and returns an array of all matches. The flags can be used to designate options when using the regular expression. Refer to RegEx documentation for more details on regular expressions.

Convert to Base64 format

StringToBase64String(any): string

Converts any input value to a string in Base64 format.

Convert from Base64 string to UTF-8 encoding

StringFromBase64String(any): string

Converts a value from a Base64 string to a regular string in UTF-8 encoding.

Encode URI component

StringEncodeURIComponent(str: string): string

Encodes a string as a valid Uniform Resource Identifier (URI) by escaping characters requiring this.

Decode URI component

StringDecodeURIComponent(str: string): string

Returns the unencoded version of an encoded Uniform Resource Identifier (URI) by unescaping characters.