Quirrel4.41.0

string

Formatting, trimming, splitting and regular expressions.

from "string" import ...

Functions

endswithpure fastcall endswith(str: string, suffix: string): boolReturns whether str ends with suffix.
escapepure escape(str: string): stringReturns str with backslash, the two quote characters, and every byte that is not printable ASCII replaced by an escape sequence.
formatpure format(fmt: string, ...): stringFormats fmt with the following arguments, following the syntax of the C printf family, and returns the result as a new string.
lstrippure fastcall lstrip(str: string): stringReturns str with white-space characters removed from the beginning only.
printfprintf(fmt: string, ...)Formats fmt with the following arguments and writes the result to the same output as print, without building and returning a throwaway string.
rstrippure fastcall rstrip(str: string): stringReturns str with white-space characters removed from the end only.
split_by_charssplit_by_chars(str: string, separators: string, [skip_empty: bool]): arraySplits str into an array of strings at every character that occurs in separators.
startswithpure fastcall startswith(str: string, prefix: string): boolReturns whether str begins with prefix.
strippure fastcall strip(str: string): stringReturns str with white-space characters removed from both ends.

regexp class

A compiled regular expression.

Functions

captureinstance.capture(str: string, [start: int]): array|nullFinds the first match of the pattern in str at or after start, and returns the whole match plus every capturing group as an array of spans.
constructorconstructor(pattern: string): instanceCompiles pattern into a reusable regexp instance.
matchinstance.match(str: string): boolReturns whether the pattern matches the whole of str.
searchinstance.search(str: string, [start: int]): table|nullFinds the first match of the pattern in str at or after start, and returns its span.
subexpcountinstance.subexpcount(): intReturns how many sub-expressions the pattern has.