Namespace: joker.string
v1.0Contents
Summary
Provides Unicode-aware string predicates, transforms, searches, and splitting helpers.
Index
- blank?
- capitalize
- ends-with?
- escape
- includes?
- index-of
- join
- last-index-of
- lower-case
- pad-left
- pad-right
- re-quote
- replace
- replace-first
- reverse
- split
- split-lines
- starts-with?
- trim
- trim-left
- trim-newline
- trim-right
- triml
- trimr
- upper-case
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
(None.)
Variables
-
(None.)
Functions, Macros, and Special Forms
-
blank?
Function v1.0(blank? s)(blank? ^Object s)True if s is nil, empty, or contains only whitespace.
show types -
capitalize
Function v1.0(capitalize s)(capitalize ^Stringable s)Converts first character of the string to upper-case, all other
show types
characters to lower-case. -
ends-with?
Function v1.0(ends-with? s substr)(ends-with? ^String s ^Stringable substr)True if s ends with substr.
show types -
escape
Function v1.0(escape s cmap)(escape ^String s ^Callable cmap)Return a new string, using cmap to escape each character ch
show types
from s as follows:
If (cmap ch) is nil, append ch to the new string.
If (cmap ch) is non-nil, append (str (cmap ch)) instead. -
includes?
Function v1.0(includes? s substr)(includes? ^String s ^Stringable substr)True if s includes substr.
show types -
index-of
Function v1.0(index-of s value)(index-of ^String s ^Object value)(index-of s value from)(index-of ^String s ^Object value ^Int from)Returns the Unicode-character index of value in s, or nil when absent.
show types
value must be a string or char. The optional from argument is a
Unicode-character index from which to begin the forward search. -
join
Function v1.0(join coll)(join ^Seqable coll)(join separator coll)(join ^Stringable separator ^Seqable coll)Returns the elements of coll joined by an optional separator.
show types
Elements are converted with their ordinary string form before joining. -
last-index-of
Function v1.0(last-index-of s value)(last-index-of ^String s ^Object value)(last-index-of s value from)(last-index-of ^String s ^Object value ^Int from)Returns the last Unicode-character index of value in s, or nil when absent.
show types
value must be a string or char. With from, only the prefix ending at that
Unicode-character index is searched. -
lower-case
Function v1.0(lower-case s)(lower-case ^Stringable s)Converts string to all lower-case.
show types -
pad-left
Function v1.0(pad-left s pad n)(pad-left ^String s ^Stringable pad ^Int n)Returns s padded with pad at the beginning to n Unicode characters.
show types
Returns s unchanged when it is already at least n characters long. pad must
be non-empty when padding is required. -
pad-right
Function v1.0(pad-right s pad n)(pad-right ^String s ^Stringable pad ^Int n)Returns s padded with pad at the end to n Unicode characters.
show types
Returns s unchanged when it is already at least n characters long. pad must
be non-empty when padding is required. -
re-quote
Function v1.0(re-quote s)(re-quote ^String s)Returns a Regex that matches s literally rather than treating it as a pattern.
show types -
replace
Function v1.0(replace s match repl)(replace ^String s ^Object match ^Stringable repl)Replaces all instances of match (String or Regex) with string repl in string s.
show types
If match is Regex, $1, $2, etc. in the replacement string repl are
substituted with the string that matched the corresponding
parenthesized group in the pattern.
-
replace-first
Function v1.0(replace-first s match repl)(replace-first ^String s ^Object match ^Stringable repl)Replaces the first instance of match (String or Regex) with string repl in string s.
show types
If match is Regex, $1, $2, etc. in repl are expanded from the corresponding
parenthesized groups, as in replace. -
reverse
Function v1.0(reverse s)(reverse ^String s)Returns s with its characters reversed.
show types -
split
Function v1.0(split s sep)(split ^String s ^Object sep)(split s sep n)(split ^String s ^Object sep ^Int n)Splits string on a string or regular expression. Returns vector of the splits.
show types
No more than n elements will be returned in the vector; the last element will
be the unsplit remainder. If n is <= 0, no limit is in effect (all substrings
are returned in the vector). -
split-lines
Function v1.0(split-lines s)(split-lines ^String s)Splits string on \n or \r\n. Returns vector of the splits.
show types -
starts-with?
Function v1.0(starts-with? s substr)(starts-with? ^String s ^Stringable substr)True if s starts with substr.
show types -
trim
Function v1.0(trim s)(trim ^String s)Removes whitespace from both ends of string.
show types -
trim-left
Function v1.0(trim-left s)(trim-left ^String s)Removes whitespace from the left side of string.
show types -
trim-newline
Function v1.0(trim-newline s)(trim-newline ^String s)Removes all trailing newline \n or return \r characters from string.
show types -
trim-right
Function v1.0(trim-right s)(trim-right ^String s)Removes whitespace from the right side of string.
show types -
triml
Function v1.0(triml s)(triml ^String s)Removes whitespace from the left side of string.
show types -
trimr
Function v1.0(trimr s)(trimr ^String s)Removes whitespace from the right side of string.
show types -
upper-case
Function v1.0(upper-case s)(upper-case ^Stringable s)Converts string to all upper-case.
show types