Janet 1.16.1-87f8fe1 Documentation
(Other Versions: 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
(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
(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
(string/bytes str)

Returns an array of integers that are the byte values of the string.
Community Examples

string/check-set 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

string/find 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

string/find-all 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

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

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

string/from-bytes 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

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

Tests whether str starts with pfx.
Community Examples

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

Tests whether str ends with sfx.
Community Examples

string/join cfunction
(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
(string/repeat bytes n)

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

string/replace 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

string/replace-all 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

string/reverse cfunction
(string/reverse str)

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

string/slice 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

string/split 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

string/trim 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

string/triml 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

string/trimr 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