Functions for working with strings.
Functions for working with strings.
(->slug s)
Take a string s
and return a slug-ified string.
For example:
(->slug "Nick's recipe" "nicks-recipe")
Take a string `s` and return a [slug-ified](https://en.wikipedia.org/wiki/Clean_URL#Slug) string. For example: ```clj (->slug "Nick's recipe" "nicks-recipe") ```
(->spongebob-case s)
Take a string s
and coerce characters alternatively between lower and upper case.
For example:
(->spongebob-case "spongebob") ;; => "sPoNgEbOb"
Take a string `s` and coerce characters alternatively between lower and upper case. For example: ```clj (->spongebob-case "spongebob") ;; => "sPoNgEbOb" ```
(->sporadic-case s)
Take a string s
and randomly coerce characters to either lower or upper case.
For example:
(->sporadic-case "hello world") ;; => "hElLo wOrLd"
(->sporadic-case "hello world") ;; => "hElLo world"
Take a string `s` and randomly coerce characters to either lower or upper case. For example: ```clj (->sporadic-case "hello world") ;; => "hElLo wOrLd" (->sporadic-case "hello world") ;; => "hElLo world" ```
An option map key to cast strings to UPPER CASE in prepare-for-compare
.
Commonly, this is set for the options
argument of same?
and includes?
.
This option will be enabled if this key's value is truthy, and is disabled by default.
An option map key to cast strings to UPPER CASE in `prepare-for-compare`. Commonly, this is set for the `options` argument of `same?` and `includes?`. This option will be enabled if this key's value is truthy, and is disabled by default.
(includes? s1 s2)
(includes? s1 s2 opts)
Checks to see if s1
includes s2
after each string has been modified by prepare-for-compare
.
An option map may be passed as an optional second argument. The following keys are supported:
:uppercase?
- If true, s1
and s2
will be coerced to upper case. Defaults to false.Example:
(includes? " Hello " "hello") ; => true
(includes? " Hello there " "hello" {:uppercase? true}) ; => true
(includes? " Hello " "goodbye" {:uppercase? false}) ; => false
Checks to see if `s1` includes `s2` after each string has been modified by `prepare-for-compare`. An option map may be passed as an optional second argument. The following keys are supported: - `:uppercase?` - If true, `s1` and `s2` will be coerced to upper case. Defaults to false. Example: ```clj (includes? " Hello " "hello") ; => true (includes? " Hello there " "hello" {:uppercase? true}) ; => true (includes? " Hello " "goodbye" {:uppercase? false}) ; => false ```
(not-blank? s)
Takes a string s
and returns false if is s
is nil, the empty string, or contains only whitespace.
Example:
(not-blank? "") ; => false
(not-blank? " ") ; => false
(not-blank? nil) ; => false
(not-blank? "Hello, there") ; => true
Takes a string `s` and returns false if is `s` is nil, the empty string, or contains only whitespace. Example: ```clj (not-blank? "") ; => false (not-blank? " ") ; => false (not-blank? nil) ; => false (not-blank? "Hello, there") ; => true ```
(same-text? s1 s2)
(same-text? s1 s2 opts)
Checks to see if s1
and s2
are equal after each string has been trim
ed and cast to the same casing.
An option map may be passed as an optional second argument. The following keys are supported:
:uppercase?
- If true, s1
and s2
will be coerced to upper case. Defaults to false.Example:
(same-text? " Hello " "hello") ; => true
(same-text? " Hello " "hello" {:uppercase? true}) ; => true
(same-text? " Hello " "goodbye" {:uppercase? false}) ; => false
Checks to see if `s1` and `s2` are equal after each string has been `trim`ed and cast to the same casing. An option map may be passed as an optional second argument. The following keys are supported: - `:uppercase?` - If true, `s1` and `s2` will be coerced to upper case. Defaults to false. Example: ```clj (same-text? " Hello " "hello") ; => true (same-text? " Hello " "hello" {:uppercase? true}) ; => true (same-text? " Hello " "goodbye" {:uppercase? false}) ; => false ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close