Janet 1.27.0-01aab66 Documentation
(Other Versions: 1.26.0 1.25.1 1.24.0 1.23.0 1.22.0 1.21.0 1.20.0 1.19.0 1.18.1 1.17.1 1.16.1 1.15.0 1.13.1 1.12.2 1.11.1 1.10.1 1.9.1 1.8.1 1.7.0 1.6.0 1.5.1 1.5.0 1.4.0 1.3.1 )

String Module

Index

string/ascii-lower string/ascii-upper string/bytes string/check-set string/find string/find-all string/format string/from-bytes string/has-prefix? string/has-suffix? string/join string/repeat string/replace string/replace-all string/reverse string/slice string/split string/trim string/triml string/trimr


string/ascii-lower cfunction source
(string/ascii-lower str)

Returns a new string where all bytes are replaced with the lowercase version of themselves in ASCII. Does only a very simple case check, meaning no unicode support.
Community Examples

string/ascii-upper cfunction source
(string/ascii-upper str)

Returns a new string where all bytes are replaced with the uppercase version of themselves in ASCII. Does only a very simple case check, meaning no unicode support.
Community Examples

string/bytes cfunction source
(string/bytes str)

Returns a tuple of integers that are the byte values of the string.
Community Examples

string/check-set cfunction source
(string/check-set set str)

Checks that the string `str` only contains bytes that appear in the string `set`. Returns true if all bytes in `str` appear in `set`, false if some bytes in `str` do not appear in `set`.
Community Examples

string/find cfunction source
(string/find patt str &opt start-index)

Searches for the first instance of pattern `patt` in string `str`. Returns the index of the first character in `patt` if found, otherwise returns nil.
Community Examples

string/find-all cfunction source
(string/find-all patt str &opt start-index)

Searches for all instances of pattern `patt` in string `str`. Returns an array of all indices of found patterns. Overlapping instances of the pattern are counted individually, meaning a byte in `str` may contribute to multiple found patterns.
Community Examples

string/format cfunction source
(string/format format & values)

Similar to C's `snprintf`, but specialized for operating with Janet values. Returns a new string.
Community Examples

string/from-bytes cfunction source
(string/from-bytes & byte-vals)

Creates a string from integer parameters with byte values. All integers will be coerced to the range of 1 byte 0-255.
Community Examples

string/has-prefix? cfunction source
(string/has-prefix? pfx str)

Tests whether `str` starts with `pfx`.
Community Examples

string/has-suffix? cfunction source
(string/has-suffix? sfx str)

Tests whether `str` ends with `sfx`.
Community Examples

string/join cfunction source
(string/join parts &opt sep)

Joins an array of strings into one string, optionally separated by a separator string `sep`.
Community Examples

string/repeat cfunction source
(string/repeat bytes n)

Returns a string that is `n` copies of `bytes` concatenated.
Community Examples

string/replace cfunction source
(string/replace patt subst str)

Replace the first occurrence of `patt` with `subst` in the string `str`. Will return the new string if `patt` is found, otherwise returns `str`.
Community Examples

string/replace-all cfunction source
(string/replace-all patt subst str)

Replace all instances of `patt` with `subst` in the string `str`. Overlapping matches will not be counted, only the first match in such a span will be replaced. Will return the new string if `patt` is found, otherwise returns `str`.
Community Examples

string/reverse cfunction source
(string/reverse str)

Returns a string that is the reversed version of `str`.
Community Examples

string/slice cfunction source
(string/slice bytes &opt start end)

Returns a substring from a byte sequence. The substring is from index `start` inclusive to index `end`, exclusive. All indexing is from 0. `start` and `end` can also be negative to indicate indexing from the end of the string. Note that index -1 is synonymous with index `(length bytes)` to allow a full negative slice range. 
Community Examples

string/split cfunction source
(string/split delim str &opt start limit)

Splits a string `str` with delimiter `delim` and returns an array of substrings. The substrings will not contain the delimiter `delim`. If `delim` is not found, the returned array will have one element. Will start searching for `delim` at the index `start` (if provided), and return up to a maximum of `limit` results (if provided).
Community Examples

string/trim cfunction source
(string/trim str &opt set)

Trim leading and trailing whitespace from a byte sequence. If the argument `set` is provided, consider only characters in `set` to be whitespace.
Community Examples

string/triml cfunction source
(string/triml str &opt set)

Trim leading whitespace from a byte sequence. If the argument `set` is provided, consider only characters in `set` to be whitespace.
Community Examples

string/trimr cfunction source
(string/trimr str &opt set)

Trim trailing whitespace from a byte sequence. If the argument `set` is provided, consider only characters in `set` to be whitespace.
Community Examples