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

cfunction (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 / source
cfunction (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 / source
cfunction (string/bytes str)
Returns a tuple of integers that are the byte values of the string.
Community Examples / source
cfunction (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 / source
cfunction (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 / source
cfunction (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 / source
cfunction (string/format format & values)
Similar to C's `snprintf`, but specialized for operating with Janet values. Returns a new string.
Community Examples / source
cfunction (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 / source
cfunction (string/has-prefix? pfx str)
Tests whether `str` starts with `pfx`.
Community Examples / source
cfunction (string/has-suffix? sfx str)
Tests whether `str` ends with `sfx`.
Community Examples / source
cfunction (string/join parts &opt sep)
Joins an array of strings into one string, optionally separated by a separator string `sep`.
Community Examples / source
cfunction (string/repeat bytes n)
Returns a string that is `n` copies of `bytes` concatenated.
Community Examples / source
cfunction (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 / source
cfunction (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 / source
cfunction (string/reverse str)
Returns a string that is the reversed version of `str`.
Community Examples / source
cfunction (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 / source
cfunction (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 / source
cfunction (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 / source
cfunction (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 / source
cfunction (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 / source