string
Formatting, trimming, splitting and regular expressions.
from "string" import ...
Functions
| endswith | pure fastcall endswith(str: string, suffix: string): bool | Returns whether str ends with suffix. |
| escape | pure escape(str: string): string | Returns str with backslash, the two quote characters, and every byte that is not printable ASCII replaced by an escape sequence. |
| format | pure format(fmt: string, ...): string | Formats fmt with the following arguments, following the syntax of the C printf family, and returns the result as a new string. |
| lstrip | pure fastcall lstrip(str: string): string | Returns str with white-space characters removed from the beginning only. |
| printf | printf(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. |
| rstrip | pure fastcall rstrip(str: string): string | Returns str with white-space characters removed from the end only. |
| split_by_chars | split_by_chars(str: string, separators: string, [skip_empty: bool]): array | Splits str into an array of strings at every character that occurs in separators. |
| startswith | pure fastcall startswith(str: string, prefix: string): bool | Returns whether str begins with prefix. |
| strip | pure fastcall strip(str: string): string | Returns str with white-space characters removed from both ends. |
regexp class
A compiled regular expression.
Functions
| capture | instance.capture(str: string, [start: int]): array|null | Finds 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. |
| constructor | constructor(pattern: string): instance | Compiles pattern into a reusable regexp instance. |
| match | instance.match(str: string): bool | Returns whether the pattern matches the whole of str. |
| search | instance.search(str: string, [start: int]): table|null | Finds the first match of the pattern in str at or after start, and returns its span. |
| subexpcount | instance.subexpcount(): int | Returns how many sub-expressions the pattern has. |