trim

trim, function

def const pure trim(t: text, toTrim: text): text

Removes characters from both ends of t. The characters to remove are listed in toTrim.

Example

const original = " Hello world! "
const trimmed1 = trim(original, " ")
const trimmed2 = trim(original, "! ")

show summary "Trim" with
  strlen(original) as "Original"
  strlen(trimmed1) as "Trimmed1"
  strlen(trimmed2) as "Trimmed2"

This outputs the following summary:

Original Trimmed1 Trimmed2
14 12 11
User Contributed Notes
0 notes + add a note