Strings
Last updated
Methods you can call on any string value with a dot. They never mutate the original string - each returns a new value. String positions are 1-indexed, matching arrays.
string name = "Ada Lovelace"
log name.toUpper() // "ADA LOVELACE"
log name.split(" ") // ["Ada", "Lovelace"]Case & Whitespace - toUpper, toLower, toTitle, trim, strip.
Searching & Testing - contains, containsAny, startsWith, endsWith, index, lastIndex, count.
Slicing & Splitting - left, right, split, toArr.
Building & Editing - append, prepend, insert, replace, replaceFirst, stripStart, stripEnd, padStart, padEnd.
Encoding, Hashing & Input - ord, btoa/atob, encodeHex/decodeHex, encodeBin/decodeBin, hashMD5/hashSHA1/hashSHA256/hashSHA512, ask.
When you pass a regex value, strings gain regex-aware behaviour:
.match(re)
boolean
Whether the regex matches anywhere.
.findAll(re)
array
All matches.
.replace(re, new)
string
Replace every regex match.
.split(re)
array
Split on the regex.
.match(pattern) with a plain string pattern returns an array of matches. See the regex package for building patterns.
Strings also support the methods shared by all values - .len (a property), .toNum(), .toInt(), .toBool(), .toStr(), .getType(), .clone(), .item(i). See Type & conversion methods.
Last updated