String

◷ Reading Time: 7 minutes

split

Splits a string into substrings that are based on the characters in an array.

 split (value, splitter, trim, remove, minimumCount)
  • value (string): a value to be split (Mandatory)
  • splitter (string, array): splitter char, string or an array of multiple splitter (Mandatory)
  • trim (bool): true to trim each item in the split list (default true)
  • remove (bool): true to remove the empty items from a split list (default true)
  • minimumCount (number): if the split count result is less, will add a null item to match the count (default -1, does not add null values)

substring

Retrieves a substring from a string value.

 substring (value, index, length)
  • value (string): a value to be used as source (Mandatory)
  • index (string): The zero-based starting character position of a substring in this instance
  • length (int): The number of characters in the substring (default 0)

asString

Converts a value to its string representation.

 asString (value, quote)

Function version of monad asString.

format

Formatting a string template based on a Native complex value.

 format (template, value)
  • template (string): a string template
  • value: a native complex value to provide values for the parameters of the template
Example: format ('this is a {ADJ} test', {ADJ: 'good'})

join

Concatenates the elements of specified members of a collection/array, using the specified separator between each member.

 join (separator, members)
  • separator: The string to use as a separator. Separator is included in the returned string only if values have more than one element (Mandatory)
  • members: list of members to concatenate (Mandatory)

concat

Concatenates the elements of specified members of a collection/array without any separator between each member.

 concat (members)
  • members: list of members to concatenate (Mandatory)

trim

Removes all leading and trailing white-space characters (or specified ones) from the current string.

 trim (stringValue, characters)
  • stringValue: the string value to trim (Mandatory)
  • characters: list of characters to be used for trim in a left to right order. Using the characters cannot be provided.

toLower

Returns a copy of this string converted to lowercase.

value toLower ()
  • value: Required

toUpper

Returns a copy of this string converted to uppercase.

value toUpper ()
  • value: Required

startsWith

Determines whether the beginning of this string instance matches a specified string.

value |startsWith (string)
  • string: Required
  • value: Required

endsWith

Determines whether the end of this string instance matches a specified string.

value |endsWith (string)
  • string: Required
  • value: Required

Regex

Executes regular expressions patterns on a string value.

regex

Determines whether a string matches a specific regular expression pattern.

 regex (input, pattern, flags)
  • input: Required
  • pattern: Required
  • flags: Optional
    • i: Specifies case-insensitive matching.
    • m: Multiline mode. Changes the meaning of ^ and $ so these respectively match at the beginning and end of any line, and not just the beginning and end of the entire string.
    • s: Specifies single-line mode. Changes the meaning of the dot (.), so that it matches every character (instead of every character except \n).
  • Returns: true or false
Example: regex ('test@gmail.com', '\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*', 'i') 

Match any characters including -_.,# and alphanumeric.

Example: regex ('##test-_123',  "^[-_.,#\\w]+$" , 'i') 

Match any number.

Example: regex ('123',  "^[0-9]*$" , 'i') 

regexMatches

Finds all the string matches based on a specific regular expression pattern.

 regex (input, pattern, groupName, flags)
  • input: Required
  • pattern: Required
  • groupName: Required. The name of regex group to list the values. The groupName must start with $ if a group name is not defined, the index can be used and must still starts with $.
  • flags: Optional
    • i: Specifies case-insensitive matching.
    • m: Multiline mode. Changes the meaning of ^ and $ so these respectively match at the beginning and end of any line, and not just the beginning and end of the entire string.
    • s: Specifies single-line mode. Changes the meaning of the dot (.), so that it matches every character (instead of every character except \n).
Example: regexMatches ('A subject with [m1] [m2]', '(\\[(.*?)\\])', '$2', 'ic')
Returns: m1, m2 

regexMatch

Similar to regexMatches but this finds the first string match based on a specific regular expression pattern.

 regexMatch (input, pattern, groupName, flags)

match

Determines whether a string matches a specific regular expression pattern.

value |match (pattern, flags)
  • pattern: Required
  • flags: Optional
    • i: Specifies case-insensitive matching.
    • m: Multiline mode. Changes the meaning of ^ and $ so these respectively match at the beginning and end of any line, and not just the beginning and end of the entire string.
    • s: Specifies single-line mode. Changes the meaning of the dot (.), so that it matches every character (instead of every character except \n).
    • c: Specifies that cultural differences in language are ignored.
    • r: Specifies that the search will be from right to left, instead of from left to right.
  • value (Required): the value must be a string value, otherwise the match result is false.
Example: "test@gmail.com" |macth ("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*","i") 

replace

Determines whether a string matches a specific regular expression pattern.

value |replace (pattern, replacement, flags)
  • pattern: Required
  • replacement: New string for the replacement
  • flags: Optional
    • i: Specifies case-insensitive matching.
    • m: Multiline mode. Changes the meaning of ^ and $ so these respectively match at the beginning and end of any line, and not just the beginning and end of the entire string.
    • s: Specifies single-line mode. Changes the meaning of the dot (.), so that it matches every character (instead of every character except \n).
    • c: Specifies that cultural differences in language are ignored.
    • r: Specifies that the search will be from right to left, instead of from left to right.
  • value: Required

You can also use a regex pattern as follows:

Example: "23.452,3"|replace("\\.","")
Returns: 23452,3 
Example: "Your email is test@gmail.com. This should be unique"|replace("\w+([-+.]\w+)@\w+([-.]\w+)\.\w+([-.]\w+)*","<your email>")
Returns: Your email is <your email>. This should be unique

Updated on August 10, 2020

Was this article helpful?

Related Articles