string
Jump to function (28) ›
- string/blank?
- string/capitalize
- string/chars
- string/contains?
- string/ends-with?
- string/escape
- string/includes?
- string/index-of
- string/join
- string/last-index-of
- string/lower-case
- string/pad-both
- string/pad-left
- string/pad-right
- string/re-quote-replacement
- string/repeat
- string/replace
- string/replace-first
- string/reverse
- string/split
- string/split-lines
- string/starts-with?
- string/subs
- string/trim
- string/trim-newline
- string/triml
- string/trimr
- string/upper-case
string/blank?#
(blank? s)
True if s is nil, empty, or contains only whitespace. Non-breaking
separators (U+00A0, U+2007, U+202F) are not treated as whitespace.
Example:
(blank? " ") ; => true
string/capitalize#
(capitalize s)
Converts first character to upper-case and all other characters to lower-case.
Example:
(capitalize "hELLO wORLD") ; => "Hello world"
string/chars#
(chars s)
Returns a vector of characters from string s.
This is a convenience function for converting strings to character sequences. Properly handles multibyte UTF-8 characters.
Example:
(chars "hello") ; => ["h" "e" "l" "l" "o"]
string/contains?#
(contains? s substr)
True if s contains substr.
Example:
(contains? "hello world" "lo wo") ; => true
string/ends-with?#
(ends-with? s substr)
True if s ends with substr.
Example:
(ends-with? "hello world" "world") ; => true
string/escape#
(escape s cmap)
Returns a new string with each character escaped according to cmap.
Example:
(escape "hello" {"h" "H" "o" "O"}) ; => "HellO"
string/includes?#
(includes? s substr)
True if s includes substr.
Example:
(includes? "hello world" "world") ; => true
string/index-of#
(index-of s value & [from-index])
Returns the index of value in s, or nil if not found.
Example:
(index-of "hello world" "world") ; => 6
string/join#
(join separator & [coll])
Returns a string of all elements in coll, separated by an optional separator.
Example:
(join ", " ["apple" "banana" "cherry"]) ; => "apple, banana, cherry"
string/last-index-of#
(last-index-of s value & [from-index])
Returns the last index of value in s, or nil if not found.
Example:
(last-index-of "hello world world" "world") ; => 12
string/lower-case#
(lower-case s)
Converts string to all lower-case.
Example:
(lower-case "HELLO World") ; => "hello world"
string/pad-both#
(pad-both s len & [pad-str])
Returns a string padded on both sides to length len.
Example:
(pad-both "hello" 11) ; => " hello "
string/pad-left#
(pad-left s len & [pad-str])
Returns a string padded on the left side to length len.
Example:
(pad-left "hello" 10) ; => " hello"
string/pad-right#
(pad-right s len & [pad-str])
Returns a string padded on the right side to length len.
Example:
(pad-right "hello" 10) ; => "hello "
string/re-quote-replacement#
(re-quote-replacement replacement)
Escapes special characters in a replacement string for literal use.
Example:
(re-quote-replacement "$1.00") ; => "\$1.00"
string/repeat#
(repeat s n)
Returns a string containing n copies of s.
Example:
(repeat "ha" 3) ; => "hahaha"
string/replace#
(replace s match replacement)
Replaces all instances of match with replacement in s.
Example:
(replace "hello world" "world" "there") ; => "hello there"
string/replace-first#
(replace-first s match replacement)
Replaces the first instance of match with replacement in s.
Example:
(replace-first "hello world world" "world" "there") ; => "hello there world"
string/reverse#
(reverse s)
Returns s with its characters reversed.
Example:
(reverse "hello") ; => "olleh"
string/split#
(split s re & [limit])
Splits string on a regular expression, returning a vector of parts.
Example:
(split "hello world foo bar" #"\s+") ; => ["hello" "world" "foo" "bar"]
string/split-lines#
(split-lines s)
Splits s on \n or \r\n. Trailing empty lines are not returned.
Example:
(split-lines "hello\nworld\ntest") ; => ["hello" "world" "test"]
string/starts-with?#
(starts-with? s substr)
True if s starts with substr.
Example:
(starts-with? "hello world" "hello") ; => true
string/subs#
(subs s start & [end])
Returns the substring of s from start (inclusive) to end (exclusive).
Example:
(subs "hello world" 0 5) ; => "hello"
string/trim#
(trim s)
Removes whitespace from both ends of string.
Example:
(trim " hello ") ; => "hello"
string/trim-newline#
(trim-newline s)
Removes all trailing newline or return characters from string.
Example:
(trim-newline "hello\n\n") ; => "hello"
string/triml#
(triml s)
Removes whitespace from the left side of string.
Example:
(triml " hello ") ; => "hello "
string/trimr#
(trimr s)
Removes whitespace from the right side of string.
Example:
(trimr " hello ") ; => " hello"
string/upper-case#
(upper-case s)
Converts string to all upper-case.
Example:
(upper-case "hello World") ; => "HELLO WORLD"