Skip to main content

String Functions

substring()​

  • parameters:
    • string: string
    • start position: number
    • (optional) length: number
  • result: string
substring("foobar",3) 
// "obar"

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

string length()​

  • parameters:
    • string: string
  • result: number
string length("foo") 
// 3

upper case()​

  • parameters:
    • string: string
  • result: string
upper case("aBc4") 
// "ABC4"

lower case()​

  • parameters:
    • string: string
  • result: string
lower case("aBc4") 
// "abc4"

substring before()​

  • parameters:
    • string: string
    • match: string
  • result: string
substring before("foobar", "bar") 
// "foo"

substring after()​

  • parameters:
    • string: string
    • match: string
  • result: string
substring after("foobar", "ob") 
// "ar"

contains()​

  • parameters:
    • string: string
    • match: string
  • result: boolean
contains("foobar", "of") 
// false

starts with()​

  • parameters:
    • input: string
    • match: string
  • result: boolean
starts with("foobar", "fo") 
// true

ends with()​

  • parameters:
    • input: string
    • match: string
  • result: boolean
ends with("foobar", "r") 
// true

matches()​

  • parameters:
    • input: string
    • pattern: string (regular expression)
  • result: boolean
matches("foobar", "^fo*bar") 
// true

replace()​

  • parameters:
    • input: string
    • pattern: string (regular expression)
    • replacement: string (e.g. $1 returns the first match group)
    • (optional) flags: string ("s", "m", "i", "x")
  • result: string
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"

split()​

  • parameters:
    • string: string
    • delimiter: string (regular expression)
  • result: list of strings
split("John Doe", "\s" ) 
// ["John", "Doe"]

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