diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/string.clj | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/clj/clojure/string.clj b/src/clj/clojure/string.clj index a50c8753..951f94a1 100644 --- a/src/clj/clojure/string.clj +++ b/src/clj/clojure/string.clj @@ -82,21 +82,6 @@ sep) (str sb))))) -(defn ^String chop - "Removes the last character of string, does nothing on a zero-length - string." - [^String s] - (let [size (count s)] - (if (zero? size) - s - (subs s 0 (dec (count s)))))) - -(defn ^String chomp - "Removes all trailing newline \\n or return \\r characters from - string. Note: String.trim() is similar and faster." - [^String s] - (replace-re #"[\r\n]+$" "" s)) - (defn ^String capitalize "Converts first character of the string to upper-case, all other characters to lower-case." @@ -106,16 +91,6 @@ (str (.toUpperCase ^String (subs s 0 1)) (.toLowerCase ^String (subs s 1))))) -(defn ^String ltrim - "Removes whitespace from the left side of string." - [^String s] - (replace-re #"^\s+" "" s)) - -(defn ^String rtrim - "Removes whitespace from the right side of string." - [^String s] - (replace-re #"\s+$" "" s)) - (defn ^String upper-case "Converts string to all upper-case." [^String s] @@ -137,3 +112,29 @@ [^String s] (.trim s)) +(defn ^String triml + "Removes whitespace from the left side of string." + [^String s] + (replace-re #"^\s+" "" s)) + +(defn ^String trimr + "Removes whitespace from the right side of string." + [^String s] + (replace-re #"\s+$" "" s)) + +(defn ^String chop + "Removes the last character of string, does nothing on a zero-length + string." + [^String s] + (let [size (count s)] + (if (zero? size) + s + (subs s 0 (dec (count s)))))) + +(defn ^String chomp + "Removes all trailing newline \\n or return \\r characters from + string. Note: String.trim() is similar and faster." + [^String s] + (replace-re #"[\r\n]+$" "" s)) + + |