tupelo.string
A superset of `clojure.string` with many added functions.
->kabob-kw
(->kabob-kw arg)
Inputs: [arg :- (s/cond-pre s/Keyword s/Str s/Symbol)]
Returns: s/Keyword
->kabob-str
(->kabob-str arg)
Inputs: [arg :- (s/cond-pre s/Keyword s/Str s/Symbol)]
Returns: s/Str
Coerce a string, keyword, or symbol to a kabob-case-string
->snake-kw
(->snake-kw arg)
Inputs: [arg :- (s/cond-pre s/Keyword s/Str s/Symbol)]
Returns: s/Keyword
->snake-str
(->snake-str arg)
Inputs: [arg :- (s/cond-pre s/Keyword s/Str s/Symbol)]
Returns: s/Str
Coerce a string, keyword, or symbol to a snake_case_string
alpha?
(alpha? & args)
Returns true iff every char passes tupelo.chars/alpha?
alphanumeric?
(alphanumeric? & args)
Returns true iff every char passes tupelo.chars/alphanumeric?
blank?
Alias for clojure.string/blank?
byte-array->str
(byte-array->str arg)
Converts a byte array to a String using the UTF-8 Charset
capitalize
Alias for clojure.string/capitalize
clip-text
(clip-text N src-str)
Inputs: [N :- s/Int src-str :- s/Str]
Returns: s/Str
Given a multi-line string, returns a string with each line clipped to a max of N chars
clojurize-key
(clojurize-key arg)
Given a string or keyword, converts to lowercase and calls str->kw-normalized
collapse-whitespace
deprecated
contains-match?
(contains-match? search-str re)
Inputs: [search-str :- s/Str re :- s/Any]
Returns: s/Bool
Returns true if the regex matches any portion of the intput string.
contains-str-frags?
(contains-str-frags? src & frags)
Inputs: [src :- s/Str & frags :- [s/Str]]
Returns: s/Bool
Returns true if the intput string contains the target string fragments.
Search fragments may be separated by zero-or-more arbitrary chars in src
contains-str?
(contains-str? search-str tgt-str)
Inputs: [search-str :- s/Str tgt-str :- s/Str]
Returns: s/Bool
Returns true if the intput string contains the target string.
digit?
(digit? & args)
Returns true iff every char passes tupelo.chars/digit?
drop
(drop n txt)
Inputs: [n :- s/Int txt :- s/Str]
Returns: s/Str
Drops the first N chars of a string, returning a string result.
ends-with?
Alias for clojure.string/ends-with?
equals-ignore-spacing?
deprecated
(equals-ignore-spacing? & args)
escape
Alias for clojure.string/escape
fgrep
(fgrep tgt text)
Inputs: [tgt :- s/Str text :- s/Str]
Given a multi-line text string, returns a string containing lines matching the target string.
grep
(grep pattern text)
Inputs: [pattern :- s/Regex text :- s/Str]
Given a multi-line text string, returns a string containing lines matching a regex pattern.
hex?
(hex? & args)
Returns true iff every char passes tupelo.chars/hex?
includes?
Alias for clojure.string/includes?
increasing-or-equal?
(increasing-or-equal? a b)
Inputs: [a :- s/Str b :- s/Str]
Returns: s/Bool
Returns true if a pair of strings are in increasing lexicographic order, or equal.
increasing?
(increasing? a b)
Inputs: [a :- s/Str b :- s/Str]
Returns: s/Bool
Returns true if a pair of strings are in increasing lexicographic order.
indent
(indent n txt)
Inputs: [n :- s/Int txt :- s/Str]
Returns: s/Str
Indents a string by pre-pending N spaces. Returns a string result.
indent-lines
(indent-lines n txt)
Inputs: [n :- s/Int txt :- s/Str]
Returns: s/Str
Splits out each line of txt using clojure.string/split-lines, then
indents each line by prepending N spaces. Joins lines together into
a single string result, with each line terminated by a single
ewline.
indent-lines-with
(indent-lines-with indent-str txt)
Inputs: [indent-str :- s/Str txt :- s/Str]
Returns: s/Str
Splits out each line of txt using clojure.string/split-lines, then
indents each line by prepending it with the supplied string. Joins lines together into
a single string result, with each line terminated by a single
ewline.
index-of
Alias for clojure.string/index-of
join
Alias for clojure.string/join
last-index-of
Alias for clojure.string/last-index-of
lower-case
Alias for clojure.string/lower-case
lowercase=
(lowercase= & args)
Inputs: [& args :- [s/Str]]
Returns: s/Bool
Compares strings for equality after applying clojure.string/lower-case.
lowercase?
(lowercase? & args)
Returns true iff every char passes tupelo.chars/lowercase?
nonblank-lines=
(nonblank-lines= & args)
Inputs: [& args :- [s/Str]]
Returns: s/Bool
Compares corresponding lines of input strings for equality using tupelo.misc/collapse-whitespace.
nonblank=
(nonblank= & args)
Inputs: [& args :- [s/Str]]
Returns: s/Bool
Compares strings for equality using tupelo.misc/collapse-whitespace.
Equivalent to separating tokens by whitespace and comparing the resulting sequences.
normalize-str
(normalize-str str-in)
Returns a 'normalized' version of str-in, stripped of leading/trailing
blanks, and with all non-alphanumeric chars converted to hyphens.
not-blank?
(not-blank? it)
Returns true if the string is not blank.
pad-left
(pad-left str-val N)
(pad-left str-val N pad-char)
Inputs: ([str-val :- s/Str N :- s/Int] [str-val :- s/Str N :- s/Int pad-char])
Returns: s/Str
Pads a string on the left until it is at least N chars in size
pad-right
(pad-right str-val N)
(pad-right str-val N pad-char)
Inputs: ([str-val :- s/Str N :- s/Int] [str-val :- s/Str N :- s/Int pad-char])
Returns: s/Str
Pads a string on the right until it is at least N chars in size
phonetic-alphabet
A map from keyword character to string phonetic name:
{:a 'alpha' :b 'bravo' :c 'charlie' :d 'delta' :e 'echo' :f 'foxtrot' :g 'golf'
:h 'hotel' :i 'india' :j 'juliett' :k 'kilo' :l 'lima' :m 'mike' :n 'november'
:o 'oscar' :p 'papa' :q 'quebec' :r 'romeo ' :s 'sierra' :t 'tango' :u 'uniform'
:v 'victor' :w 'whiskey' :x 'x-ray' :y 'yankee' :z 'zulu' }
pluralize-with
(pluralize-with N base-str)
Returns `base-str` when N=1; otherwise appends an `s`
quotes->double
(quotes->double arg)
Inputs: [arg :- s/Str]
Returns: s/Str
Converts all single-quotes in a string to double-quotes
quotes->single
(quotes->single arg)
Inputs: [arg :- s/Str]
Returns: s/Str
Converts all double-quotes in a string to single-quotes
re-quote-replacement
Alias for clojure.string/re-quote-replacement
replace
Alias for clojure.string/replace
replace-first
Alias for clojure.string/replace-first
reverse
Alias for clojure.string/reverse
split
Alias for clojure.string/split
split-lines
Alias for clojure.string/split-lines
starts-with?
Alias for clojure.string/starts-with?
str->byte-array
(str->byte-array arg)
Converts a String to a byte array using the UTF-8 Charset
str->kw-normalized
(str->kw-normalized arg)
Returns a keyword constructed from a normalized string
str-keep-left
(str-keep-left str-val n)
Keeps the N left-most chars of a string
str-keep-right
(str-keep-right str-val n)
Keeps the N right-most chars of a string
string->stream
(string->stream str-val)
Inputs: [str-val :- s/Str]
Returns: InputStream
tabs->spaces
(tabs->spaces src-str)
(tabs->spaces tab-size src-str)
Inputs: ([src-str :- s/Str] [tab-size :- s/Int src-str :- s/Str])
Returns: s/Str
Replaces all tabs with appropriate number of spaces (default tab-size => 8)
Usage:
(tabs->spaces 'abc<tab>def' => 'ab cd'
(tabs->spaces 4 'ab<tab>cd' => 'ab cd'
take
(take n txt)
Inputs: [n :- s/Int txt :- s/Str]
Returns: s/Str
Drops the first N chars of a string, returning a string result.
text?
(text? & args)
Returns true iff every char passes tupelo.chars/text?
trim
Alias for clojure.string/trim
trim-newline
Alias for clojure.string/trim-newline
triml
Alias for clojure.string/triml
trimr
Alias for clojure.string/trimr
upper-case
Alias for clojure.string/upper-case
uppercase?
(uppercase? & args)
Returns true iff every char passes tupelo.chars/uppercase?
visible?
(visible? & args)
Returns true iff every char passes tupelo.chars/visible?
walk-clojurize-keys
(walk-clojurize-keys form)
Recursively walks form, normalizing all map keys via `clojurize-key`.
walk-keywords->strings
(walk-keywords->strings form)
Recursively walks form, converting all keywords to strings.
walk-strings->keywords
(walk-strings->keywords form)
Recursively walks form, converting all strings to keywords.
whitespace-collapse
(whitespace-collapse arg)
Inputs: [arg :- s/Str]
Returns: s/Str
Replaces all consecutive runs of whitespace characters (including newlines) with a single space.
Removes any leading or trailing whitespace. Returns a string composed of all tokens
separated by a single space.
whitespace-eol?
(whitespace-eol? & args)
Returns true iff every char passes tupelo.chars/whitespace-eol?
whitespace-horiz?
(whitespace-horiz? & args)
Returns true iff every char passes tupelo.chars/whitespace-horiz?
whitespace-remove
(whitespace-remove arg)
Inputs: [arg :- s/Str]
Returns: s/Str
Removes all whitespace characters (including newlines) from string.
whitespace?
(whitespace? & args)
Returns true iff every char passes tupelo.chars/whitespace?