Skip to content

text

The text Library is part of the Standard Library, so every Group holds it. A Script imports the names it uses, as in use pad from text. Its normative source is spec/stdlib/text.talk, and the full rules are in chapter 7.

An argument of the wrong kind raises wrong kind before any work is done, so the entries below list only the other errors each raises (every stdlib function).

pad(t, width, fill = " ")

t with fill added at the end until it is width Characters long.

Also raises: out of domain.

padLeft(t, width, fill = " ")

t with fill added at the start until it is width Characters long.

Also raises: out of domain.

trim(t)

t without the white space at its start and end.

trimStart(t)

t without the white space at its start.

trimEnd(t)

t without the white space at its end.

split(t, separator)

The list of the texts between the matches of separator, a text or a Text Pattern, in t.

Also raises: out of domain.

join(xs, separator = "")

The items of xs, each shown as & shows it, with separator between each pair.

repeated(t, n)

n copies of t, joined.

Also raises: out of domain.

lastOffset(needle, t)

The Character position where the last match of needle, a text or a Text Pattern, starts in t, or 0 if there is none.

format(template, values)

template with each ${name} replaced by the value of that key of values, shown as & shows it.

Also raises: out of domain.

formatNumber(n, symbols, places = nothing)

The number n written with a Locale’s numberSymbols, rounded to places digits after the point if places is given.

Also raises: out of domain.

parseNumber(t, symbols)

The number t writes with a Locale’s numberSymbols.

Also raises: can't convert, out of domain.