diff options
author | David Liebke and Stuart Halloway <pair@clojure.com> | 2010-05-28 10:47:29 -0400 |
---|---|---|
committer | Stuart Halloway <stu@thinkrelevance.com> | 2010-06-03 21:20:58 -0400 |
commit | 8c0022f29cc3ddc6cfb8b1cacd8839425620b18d (patch) | |
tree | 56e0c119ad6b40b0add67a818e85747ad707ecad /src | |
parent | 4997e807b5962443eb2c41463cb1432b7cc5f613 (diff) |
trim variants differ by suffix, for sortability
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
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)) + + |