Skip to main content

String

Library of functions for the string type.

Functions

Base64

Returns the base64 encoding of a string

Syntax:
String.Base64(string: string)
Parameters
  • string: The string to encode as base64.
Example:
String.Base64("Hello World!")

CountSubString

Count the number of occurrences of a substring in a string.

Syntax:
String.CountSubString(string: string, substring: string)
Parameters
  • string: The string on which the occurrences are counted.
  • substring: The substring which is counted.
Example:
String.CountSubString("aXbX", "X")    // 2
String.CountSubString("aXbX", "y") // 0
String.CountSubString("aXbX", "aX") // 1

Decode

Builds a string from a binary, given an encoding.

Syntax:
String.Decode(string: string, encoding: string)
Parameters
  • string: The string to decode.
  • encoding: The encoding that the binary value uses.
Example:

let
b = String.Encode("Hello world", "utf-8")
in
String.Decode(b, "utf-8") // "Hello world"

Empty

Returns true the string is empty.

Syntax:
String.Empty(string: string)
Parameters
  • string: The string to check if empty.
Example:
String.Empty("") // true
String.Empty("Hello!") // false
"

Encode

Converts a string to a binary, given an encoding.

Syntax:
String.Encode(string: string, encoding: string)
Parameters
  • string: The string to encode.
  • encoding: The encoding to use.
Example:
String.EncodeString("Hello world", "utf-8")

From

Builds a string from a number, bool or temporal.

Syntax:
String.From(value: number or bool or temporal)
Parameters
  • value: The value to convert to string.
Example:
String.From(123) // "123"
String.From(true) // "true"
String.From(Date.Build(1975, 6, 23)) // " 1975-06-23"

LTrim

Removes white space characters from the beginning of a string.

Syntax:
String.LTrim(string: string)
Parameters
  • string: The string to be trimmed.
Example:
String.LTrim("  abc ") // "abc "
String.LTrim("abc ") // "abc "
String.LTrim(null) // null

Length

Compute the size of a string.

Syntax:
String.Length(string: string)
Parameters
  • string: The string to compute the size.
Example:
String.Length("Hello John") // 10

LevenshteinDistance

Calculates the Levenshtein distance between two strings. The Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other.

Syntax:
String.LevenshteinDistance(string1: string, string2: string)
Parameters
  • string1: The string from which the levenshtein distance is calculated.
  • string2: The string to which the levenshtein distance is calculated.
Example:
String.LevenshteinDistance("Hello world", "Hello warld") // 1
String.LevenshteinDistance("Hello world", "Hello John") // 4

Lower

Convert a string to lowercase.

Syntax:
String.Lower(string: string)
Parameters
  • string: The string to convert to lowercase.
Example:
lower("abC") // "abc"
lower(null) // null

RTrim

Removes white space characters from the end of a string.

Syntax:
String.RTrim(string: string)
Parameters
  • string: The string to be trimmed.
Example:
String.RTrim("  abc ") // "  abc"
String.RTrim(" abc") // " abc"

Read

Reads the contents of a location as a string.

Syntax:
String.Read(location: location)
Parameters
  • location: The location to read.

ReadLines

Reads the contents of a location as lines of text

Syntax:
String.ReadLines(location: location, encoding: optional string)
Parameters
  • location: The location to read lines from.
  • encoding: Specifies the encoding of the data; if not specified defaults to utf-8.
Example:
String.ReadLines("http://somewhere/data.log") // ["line1", "line2", ...] "

Replace

Replace all matches of substring by a new string.

Syntax:
String.Replace(string: string, pattern: string, newSubString: string)
Parameters
  • string: The string to be analyzed.
  • pattern: The substring to match.
  • newSubString: The new substring to replace matches with.
Example:
String.Replace("Hello John", "John", "Jane") // "Hello Jane"
String.Replace("Hello John", "o", "+") // "Hell+ J+hn!"

Replicate

Replicates a string by coping the substring for the specific number of repetitions.

Syntax:
String.Replicate(string: string, repetitions: int)
Parameters
  • string: The string to replicate.
  • repetitions: The number of repetitions.
Example:
String.Replicate("x", 4) // "xxxx"
String.Replicate("abc,", 2) // "abc,abc,"

Reverse

Reverses a string.

Syntax:
String.Reverse(string: string)
Parameters
  • string: The string to reverse.
Example:
String.Reverse("1234") // "4321"

Split

Split a string into a list of strings given a separator.

Syntax:
String.Split(string: string, separator: string)
Parameters
  • string: The string to split.
  • separator: The separator by which the string is split.
Example:
String.Split("Value1||Value2", "||") // ["Value1","Value2"]
String.Split("Value1|Value2", "|") // ["Value1","Value2"]

StartsWith

Returns true if the beginning of a string matches a prefix.

Syntax:
String.StartsWith(string: string, prefix: string)
Parameters
  • string: The string to find the prefix.
  • prefix: The prefix to match.
Example:
String.StartsWith("Hello world", "Hello") // true
String.StartsWith("Hello world", "world") // false
"

SubString

Extract a substring from a string, given the start index and length of extraction. Index starts at 1. A negative number as the length means the remainder of the string.

Syntax:
String.SubString(string: string, index: int, size: int)
Parameters
  • string: The string of which a substring is extracted.
  • index: The start position to extract from.
  • size: The size of the substring to extract.
Example:
String.SubString("Hello John", 4, 2) // "lo"
String.SubString("Hello John", 7, -1) // "John"

Trim

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

Syntax:
String.Trim(string: string)
Parameters
  • string: The string to be trimmed.
Example:
trim("  abc ") // "abc"
trim("abc ") // "abc"

Upper

Convert a string to uppercase.

Syntax:
String.Upper(string: string)
Parameters
  • string: The string to convert to uppercase.
Example:
String.Upper("abC") // "ABC"
String.Upper(null) // null