CrossClj

1.2.0 docs

SourceDocs



RECENT
    VARS
    as-str
    blank?
    butlast
    capitalize
    chomp
    chop
    codepoints
    dochars
    docodepoints
    drop
    escape
    get
    grep
    join
    lower-case
    ltrim
    map-str
    partition
    repeat
    replace-by
    replace-char
    replace-first-by
    replace-first-re
    replace-first-str
    replace-re
    replace-str
    reverse
    rtrim
    split
    split-lines
    substring?
    swap-case
    tail
    take
    trim
    upper-case

    « Index of all namespaces of this project

    This is a library of string manipulation functions.  It
    is intented as a replacement for clojure.contrib.string.
    
    You cannot (use 'clojure.contrib.string) because it defines
    functions with the same names as functions in clojure.core.
    Instead, do (require '[clojure.contrib.string :as s]) 
    or something similar.
    
    Goals:
      1. Be functional
      2. Most significant argument LAST, to work with ->>
      3. At least O(n) performance for Strings of length n
    
    Some ideas are borrowed from
    http://github.com/francoisdevlin/devlinsf-clojure-utils/

    — Stuart Sierra

    (as-str)(as-str x)(as-str x & ys)
    Like clojure.core/str, but if an argument is a keyword or symbol,
    its name will be used instead of its literal representation.
    
    Example:
       (str :foo :bar)     ;;=> ":foo:bar"
       (as-str :foo :bar)  ;;=> "foobar" 
    
    Note that this does not apply to keywords or symbols nested within
    data structures; they will be rendered as with str.
    
    Example:
       (str {:foo :bar})     ;;=> "{:foo :bar}"
       (as-str {:foo :bar})  ;;=> "{:foo :bar}" 
    Deprecated
    (blank? s)
    True if s is nil, empty, or contains only whitespace.
    
    (butlast n s)
    Returns s without the last n characters.  Returns an empty string
    if n is greater than the length of s.
    Deprecated
    (capitalize s)
    Converts first character of the string to upper-case, all other
    characters to lower-case.
    Deprecated
    (chomp s)
    Removes all trailing newline \n or return \r characters from
    string.  Note: String.trim() is similar and faster.
    Deprecated in 1.2. Use clojure.string/trim-newline
    (chop s)
    Removes the last character of string, does nothing on a zero-length
    string.
    (codepoints s)
    Returns a sequence of integer Unicode code points in s.  Handles
    Unicode supplementary characters (above U+FFFF) correctly.
    macro
    (dochars bindings & body)
    bindings => [name string]
    
    Repeatedly executes body, with name bound to each character in
    string.  Does NOT handle Unicode supplementary characters (above
    U+FFFF).
    macro
    (docodepoints bindings & body)
    bindings => [name string]
    
    Repeatedly executes body, with name bound to the integer code point
    of each Unicode character in the string.  Handles Unicode
    supplementary characters (above U+FFFF) correctly.
    (drop n s)
    Drops first n characters from s.  Returns an empty string if n is
    greater than the length of s.
    Deprecated
    (escape cmap s)
    Returns a new String by applying cmap (a function or a map) to each
    character in s.  If cmap returns nil, the original character is
    added to the output unchanged.
    Deprecated
    (get s i)
    Gets the i'th character in string.
    
    (grep re coll)
    Filters elements of coll by a regular expression.  The String
    representation (with str) of each element is tested with re-find.
    Deprecated
    (join separator coll)
    Returns a string of all elements in coll, separated by
    separator.  Like Perl's join.
    Deprecated
    (lower-case s)
    Converts string to all lower-case.
    
    Deprecated
    (ltrim s)
    Removes whitespace from the left side of string.
    Deprecated in 1.2. Use clojure.string/triml.
    (map-str f coll)
    Apply f to each element of coll, concatenate all results into a
    String.
    (partition re s)
    Splits the string into a lazy sequence of substrings, alternating
    between substrings that match the patthern and the substrings
    between the matches.  The sequence always starts with the substring
    before the first match, or an empty string if the beginning of the
    string matches.
    
    For example: (partition #"[a-z]+" "abc123def")
    returns: ("" "abc" "123" "def")
    (repeat n s)
    Returns a new String containing s repeated n times.
    
    Deprecated
    (replace-by re f s)
    Replaces all matches of re in s with the result of 
    (f (re-groups the-match)).
    Deprecated
    (replace-char a b s)
    Replaces all instances of character a with character b in s.
    
    Deprecated
    (replace-first-by re f s)
    Replace first match of re in s with the result of
    (f (re-groups the-match)).
    Deprecated
    (replace-first-re re replacement s)
    Replace first match of re in s.
    
    Deprecated
    (replace-first-str a b s)
    Replace first occurance of substring a with b in s.
    
    Deprecated
    (replace-re re replacement s)
    Replaces all matches of re with replacement in s.
    
    Deprecated
    (replace-str a b s)
    Replaces all instances of substring a with b in s.
    
    Deprecated
    (reverse s)
    Returns s with its characters reversed.
    
    Deprecated
    (rtrim s)
    Removes whitespace from the right side of string.
    Deprecated in 1.2. Use clojure.string/trimr.
    Deprecated
    (split re s)(split re limit s)
    Splits string on a regular expression.  Optional argument limit is
    the maximum number of splits.
    Deprecated
    (split-lines s)
    Splits s on \n or \r\n.
    
    (substring? substring s)
    True if s contains the substring.
    
    (swap-case s)
    Changes upper case characters to lower case and vice-versa.
    Handles Unicode supplementary characters correctly.  Uses the
    locale-sensitive String.toUpperCase() and String.toLowerCase()
    methods.
    (tail n s)
    Returns the last n characters of s.
    
    (take n s)
    Take first n characters from s, up to the length of s.
    
    Deprecated
    (trim s)
    Removes whitespace from both ends of string.
    
    Deprecated
    (upper-case s)
    Converts string to all upper-case.