W3cubDocs

/Clojure 1.7

clojure.string

Full namespace name: clojure.string

Overview

Public Variables and Functions

blank?function

Usage: (blank? s)
True if s is nil, empty, or contains only whitespace.

Added in Clojure version 1.2

Source

capitalizefunction

Usage: (capitalize s)
Converts first character of the string to upper-case, all other
characters to lower-case.

Added in Clojure version 1.2

Source

escapefunction

Usage: (escape s cmap)
Return a new string, using cmap to escape each character ch
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.

Added in Clojure version 1.2

Source

joinfunction

Usage: (join coll)
       (join separator coll)
Returns a string of all elements in coll, as returned by (seq coll),
separated by an optional separator.

Added in Clojure version 1.2

Source

lower-casefunction

Usage: (lower-case s)
Converts string to all lower-case.

Added in Clojure version 1.2

Source

re-quote-replacementfunction

Usage: (re-quote-replacement replacement)
Given a replacement string that you wish to be a literal
replacement for a pattern match in replace or replace-first, do the
necessary escaping of special characters in the replacement.

Added in Clojure version 1.5

Source

replacefunction

Usage: (replace s match replacement)
Replaces all instance of match with replacement in s.

match/replacement can be:

string / string
char / char
pattern / (string or function of match).

See also replace-first.

The replacement is literal (i.e. none of its characters are treated
specially) for all cases above except pattern / string.

For pattern / string, $1, $2, etc. in the replacement string are
substituted with the string that matched the corresponding
parenthesized group in the pattern.  If you wish your replacement
string r to be used literally, use (re-quote-replacement r) as the
replacement argument.  See also documentation for
java.util.regex.Matcher's appendReplacement method.

Example:
(clojure.string/replace "Almost Pig Latin" #"\b(\w)(\w+)\b" "$2$1ay")
-> "lmostAay igPay atinLay"

Added in Clojure version 1.2

Source

replace-firstfunction

Usage: (replace-first s match replacement)
Replaces the first instance of match with replacement in s.

match/replacement can be:

char / char
string / string
pattern / (string or function of match).

See also replace.

The replacement is literal (i.e. none of its characters are treated
specially) for all cases above except pattern / string.

For pattern / string, $1, $2, etc. in the replacement string are
substituted with the string that matched the corresponding
parenthesized group in the pattern.  If you wish your replacement
string r to be used literally, use (re-quote-replacement r) as the
replacement argument.  See also documentation for
java.util.regex.Matcher's appendReplacement method.

Example:
(clojure.string/replace-first "swap first two words"
                              #"(\w+)(\s+)(\w+)" "$3$2$1")
-> "first swap two words"

Added in Clojure version 1.2

Source

reversefunction

Usage: (reverse s)
Returns s with its characters reversed.

Added in Clojure version 1.2

Source

splitfunction

Usage: (split s re)
       (split s re limit)
Splits string on a regular expression.  Optional argument limit is
the maximum number of splits. Not lazy. Returns vector of the splits.

Added in Clojure version 1.2

Source

split-linesfunction

Usage: (split-lines s)
Splits s on \n or \r\n.

Added in Clojure version 1.2

Source

trimfunction

Usage: (trim s)
Removes whitespace from both ends of string.

Added in Clojure version 1.2

Source

trim-newlinefunction

Usage: (trim-newline s)
Removes all trailing newline \n or return \r characters from
string.  Similar to Perl's chomp.

Added in Clojure version 1.2

Source

trimlfunction

Usage: (triml s)
Removes whitespace from the left side of string.

Added in Clojure version 1.2

Source

trimrfunction

Usage: (trimr s)
Removes whitespace from the right side of string.

Added in Clojure version 1.2

Source

upper-casefunction

Usage: (upper-case s)
Converts string to all upper-case.

Added in Clojure version 1.2

Source

© Rich Hickey
Licensed under the Eclipse Public License 1.0.
https://clojure.github.io/clojure/branch-clojure-1.7.0/clojure.string-api.html