(<< & strings)
A backward compatibility alias for istr
macro.
A backward compatibility alias for `istr` macro.
(<<- s)
(<<- r s)
Unindent multiline text. Uses either a supplied regex or the shortest beginning-of-line to non-whitespace distance
DEPRECTED: replaced by uninindent
Unindent multiline text. Uses either a supplied regex or the shortest beginning-of-line to non-whitespace distance DEPRECTED: replaced by `uninindent`
(alnum? s)
Checks if a string contains only alphanumeric characters.
Checks if a string contains only alphanumeric characters.
(alpha? s)
Checks if a string contains only alpha characters.
Checks if a string contains only alpha characters.
(blank? s)
Checks if is a nil, empty string or contains only whitespace.
Checks if is a nil, empty string or contains only whitespace.
(camel s)
Output will be: lowerUpperUpperNoSpaces accepts strings and keywords
Output will be: lowerUpperUpperNoSpaces accepts strings and keywords
(capital s)
Uppercases the first character of a string
Uppercases the first character of a string
(chars s)
Split a string in a seq of chars.
Split a string in a seq of chars.
(clean s)
Trim and replace multiple spaces with a single space.
Trim and replace multiple spaces with a single space.
(collapse-whitespace s)
Converts all adjacent whitespace characters to a single space.
Converts all adjacent whitespace characters to a single space.
(concat & params)
A macro variant of the clojure.core/str function that performs
considerably faster string concatenation operation on CLJS (on
JVM/CLJ it only applies basic simplification and then relies on the
clojure.core/str
).
A macro variant of the clojure.core/str function that performs considerably faster string concatenation operation on CLJS (on JVM/CLJ it only applies basic simplification and then relies on the `clojure.core/str`).
(css-selector s)
Output will be either: (js-selector "LeadingDash") ;; => -leading-dash (js-selector "noLeadingDash") ;; => no-leading-dash
accepts keywords and strings, with any standard delimiter
Output will be either: (js-selector "LeadingDash") ;; => -leading-dash (js-selector "noLeadingDash") ;; => no-leading-dash accepts keywords and strings, with any standard delimiter
(digits? s)
Checks if a string contains only digit characters.
Checks if a string contains only digit characters.
(empty-or-nil? s)
Convenient helper for check emptines or if value is nil
DEPRECATED: this is already covered by empty?
Convenient helper for check emptines or if value is nil DEPRECATED: this is already covered by `empty?`
(ends-with? s suffix)
Check if the string ends with suffix.
Check if the string ends with suffix.
(ffmt s & params)
Alternative (to istr
) string formating macro, that performs simple
string formating on the compile time (this means that the string
should be known at compile time). Internally it uses the fast string
concatenation mechanism implemented in the concat
macro.
If you don't need the peculiarities of the istr
macro, this macro
should be prefered.
It works with two basic forms: sequencial and indexed. Let seen an example:
(str/ffmt "url(%)" my-url) ; sequential (str/ffmt "url(%1)" my-url) ; indexed
Alternative (to `istr`) string formating macro, that performs simple string formating on the compile time (this means that the string should be known at compile time). Internally it uses the fast string concatenation mechanism implemented in the `concat` macro. If you don't need the peculiarities of the `istr` macro, this macro should be prefered. It works with two basic forms: sequencial and indexed. Let seen an example: (str/ffmt "url(%)" my-url) ; sequential (str/ffmt "url(%1)" my-url) ; indexed
A shorter alias to format
function.
A shorter alias to `format` function.
(format s & more)
Simple string interpolation.
Simple string interpolation.
(human s)
Output will be: lower cased and space separated accepts strings and keywords
Output will be: lower cased and space separated accepts strings and keywords
(includes? s subs)
Determines whether a string contains a substring.
Determines whether a string contains a substring.
(istr & strings)
A string formating macro that works LIKE ES6 template literals but using clojure construcs and symbols for interpolation delimiters.
It accepts one or more strings; emits a concat
invocation that
concatenates the string data and evaluated expressions contained
within that argument.
Evaluation is controlled using ~{} and ~() forms. The former is used for simple value replacement using clojure.core/str; the latter can be used to embed the results of arbitrary function invocation into the produced string.
Examples:
user=> (def v 30.5) user=> (istr "This trial required ~{v}ml of solution.") "This trial required 30.5ml of solution." user=> (istr "There are ~(int v) days in November.") "There are 30 days in November."
user=> (def m {:a [1 2 3]}) user=> (istr "The total for your order is $~(->> m :a (apply +)).") "The total for your order is $6."
user=> (istr "Just split a long interpolated string up into ~(-> m :a (get 0)), " "~(-> m :a (get 1)), or even ~(-> m :a (get 2)) separate strings " "if you don't want a << expression to end up being e.g. ~(* 4 (int v)) " "columns wide.") "Just split a long interpolated string up into 1, 2, or even 3 separate strings if you don't want a << expression to end up being e.g. 120 columns wide."
Note that quotes surrounding string literals within ~() forms must be escaped.
A string formating macro that works LIKE ES6 template literals but using clojure construcs and symbols for interpolation delimiters. It accepts one or more strings; emits a `concat` invocation that concatenates the string data and evaluated expressions contained within that argument. Evaluation is controlled using ~{} and ~() forms. The former is used for simple value replacement using clojure.core/str; the latter can be used to embed the results of arbitrary function invocation into the produced string. Examples: user=> (def v 30.5) user=> (istr "This trial required ~{v}ml of solution.") "This trial required 30.5ml of solution." user=> (istr "There are ~(int v) days in November.") "There are 30 days in November." user=> (def m {:a [1 2 3]}) user=> (istr "The total for your order is $~(->> m :a (apply +)).") "The total for your order is $6." user=> (istr "Just split a long interpolated string up into ~(-> m :a (get 0)), " "~(-> m :a (get 1)), or even ~(-> m :a (get 2)) separate strings " "if you don't want a << expression to end up being e.g. ~(* 4 (int v)) " "columns wide.") "Just split a long interpolated string up into 1, 2, or even 3 separate strings if you don't want a << expression to end up being e.g. 120 columns wide." Note that quotes surrounding string literals within ~() forms must be escaped.
(join coll)
(join separator coll)
Joins strings together with given separator.
Joins strings together with given separator.
(js-selector s)
Output will be either: (js-selector "-pascal-case-me") ;; => PascalCaseMe (js-selector "camel-case-me") ;; => camelCaseMe
accepts keywords and strings, with any standard delimiter
Output will be either: (js-selector "-pascal-case-me") ;; => PascalCaseMe (js-selector "camel-case-me") ;; => camelCaseMe accepts keywords and strings, with any standard delimiter
(kebab s)
Output will be: lower-cased-and-separated-with-dashes accepts strings and keywords
Output will be: lower-cased-and-separated-with-dashes accepts strings and keywords
(keyword k)
(keyword n k)
Safer version of clojure keyword, accepting a symbol for the namespace and kebab-casing the key
Safer version of clojure keyword, accepting a symbol for the namespace and kebab-casing the key
(letters? s)
Checks if string contains only letters. This function will use all the unicode range.
Checks if string contains only letters. This function will use all the unicode range.
(lines s)
Return a list of the lines in the string.
Return a list of the lines in the string.
(lower s)
Converts string to all lower-case.
This function works in strictly locale independent way,
if you want a localized version, just use locale-lower
Converts string to all lower-case. This function works in strictly locale independent way, if you want a localized version, just use `locale-lower`
(ltrim s)
(ltrim s chs)
Removes whitespace or specified characters from left side of string.
Removes whitespace or specified characters from left side of string.
(nilv v)
Mark a expression string safe, if value is nil or undefined, the "" is returned.
Mark a expression string safe, if value is nil or undefined, the "" is returned.
(numeric? s)
Check if a string contains only numeric values.
Check if a string contains only numeric values.
(one-of? coll s)
Returns true if s can be found in coll.
Returns true if s can be found in coll.
(pad s)
(pad s {:keys [length padding type] :or {length 0 padding " " type :left}})
Pads the str with characters until the total string length is equal to the passed length parameter. By default, pads on the left with the space char.
Pads the str with characters until the total string length is equal to the passed length parameter. By default, pads on the left with the space char.
(pascal s)
Output will be: CapitalizedAndTouchingTheNext accepts strings and keywords
Output will be: CapitalizedAndTouchingTheNext accepts strings and keywords
(phrase s)
Output will be: Space separated with the first letter capitalized. accepts strings and keywords
Output will be: Space separated with the first letter capitalized. accepts strings and keywords
(prune s num)
(prune s num subs)
Truncates a string to a certain length and adds '...' if necessary.
Truncates a string to a certain length and adds '...' if necessary.
(repeat s)
(repeat s n)
Repeats string n times.
Repeats string n times.
(replace s match replacement)
Replaces all instance of match with replacement in s.
The replacement is literal (i.e. none of its characters are treated specially) for all cases above except pattern / string.
In match is pattern instance, replacement can contain $1, $2, etc. will be substituted with string that matcher the corresponding parenthesized group in pattern.
If you wish your replacement string to be used literary,
use (cuerdas.regexp/escape replacement)
.
Example: (replace "Almost Pig Latin" #"\b(\w)(\w+)\b" "$2$1ay") ;; => "lmostAay igPay atinLay"
Replaces all instance of match with replacement in s. The replacement is literal (i.e. none of its characters are treated specially) for all cases above except pattern / string. In match is pattern instance, replacement can contain $1, $2, etc. will be substituted with string that matcher the corresponding parenthesized group in pattern. If you wish your replacement string to be used literary, use `(cuerdas.regexp/escape replacement)`. Example: (replace "Almost Pig Latin" #"\b(\w)(\w+)\b" "$2$1ay") ;; => "lmostAay igPay atinLay"
(replace-first s match replacement)
Replaces first instance of match with replacement in s.
Replaces first instance of match with replacement in s.
(rtrim s)
(rtrim s chs)
Removes whitespace or specified characters from right side of string.
Removes whitespace or specified characters from right side of string.
(slice s begin)
(slice s begin end)
Extracts a section of a string and returns a new string.
Extracts a section of a string and returns a new string.
(slug s)
Transform text into a URL slug.
Transform text into a URL slug.
(snake s)
Output will be: lower_cased_and_underscore_separated accepts strings and keywords
Output will be: lower_cased_and_underscore_separated accepts strings and keywords
(split s)
(split s sep)
(split s sep num)
Splits a string on a separator a limited number of times. The separator can be a string, character or Pattern (clj) / RegExp (cljs) instance.
Splits a string on a separator a limited number of times. The separator can be a string, character or Pattern (clj) / RegExp (cljs) instance.
(starts-with? s prefix)
Check if the string starts with prefix.
Check if the string starts with prefix.
(strip-newlines s)
Takes a string and replaces newlines with a space. Multiple lines are replaced with a single space.
Takes a string and replaces newlines with a space. Multiple lines are replaced with a single space.
(strip-prefix s prefix)
Strip prefix in more efficient way.
Strip prefix in more efficient way.
(strip-suffix s suffix)
Strip suffix in more efficient way.
Strip suffix in more efficient way.
(strip-tags s)
(strip-tags s tags)
(strip-tags s tags mapping)
Remove html tags from string.
Remove html tags from string.
(substr-between s prefix suffix)
Find string that is nested in between two strings. Return first match
Find string that is nested in between two strings. Return first match
(surround s wrap)
Surround a string with another string or character.
Surround a string with another string or character.
(title s)
Output will be: Each Word Capitalized And Separated With Spaces accepts strings and keywords
Output will be: Each Word Capitalized And Separated With Spaces accepts strings and keywords
(to-bool s)
Returns true for 1/on/true/yes string values (case-insensitive), false otherwise.
Returns true for 1/on/true/yes string values (case-insensitive), false otherwise.
(trim s)
(trim s chs)
Removes whitespace or specified characters from both ends of string.
Removes whitespace or specified characters from both ends of string.
(unescape-html s)
Converts entity characters to HTML equivalents.
Converts entity characters to HTML equivalents.
(unindent s)
(unindent s re)
Unindent multiline text. Uses either a supplied regex or the shortest beginning-of-line to non-whitespace distance
Unindent multiline text. Uses either a supplied regex or the shortest beginning-of-line to non-whitespace distance
(unlines s)
Returns a new string joining a list of strings with a newline char (\n).
Returns a new string joining a list of strings with a newline char (\n).
(unsafe-concat & params)
Unsafe variant of concat
. Does not add checks on unknown symbols.
Unsafe variant of `concat`. Does not add checks on unknown symbols.
(unsafe-ends-with? s suffix)
UNSAFE version of ends-with? predicate
UNSAFE version of ends-with? predicate
(unsafe-starts-with? s prefix)
UNSAFE version of starts-with? predicate
UNSAFE version of starts-with? predicate
(unsurround s surrounding)
Unsurround a string surrounded by another string or character.
Unsurround a string surrounded by another string or character.
(upper s)
Converts string to all upper-case.
This function works in strictly locale independent way,
if you want a localized version, just use locale-upper
Converts string to all upper-case. This function works in strictly locale independent way, if you want a localized version, just use `locale-upper`
(uslug s)
Unicode friendly version of slug
function.
Unicode friendly version of `slug` function.
(word? s)
Checks if a string contains only the word characters. This function will use all the unicode range.
Checks if a string contains only the word characters. This function will use all the unicode range.
(words s)
(words s re)
Returns a vector of the words in the string.
Returns a vector of the words in the string.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close