slice
Module Export
text |> ( from: number, length: number|nothing) => text
Extracts a substring from an input text.
A negative from
value searches from the end. length
is optional, if not specified the rest of the input start at from
will be returned. length
can also be negative, in which case letters will be returned up until this position from the end.
If input is not large enough to fit the slice, it will be performed on best effort. The function will never error, but may return an empty text.
Examples
Get first 3 letters
import { slice } from 'text'
from 'text' slice(0,3)// Returns:'tex'
Get last 3 letters
import { slice } from 'text'
from 'text' slice(-3)// Returns:'ext'
Get second to next last
import { slice } from 'text'
from 'text' slice(1,-1)
// Returns:'ex'