summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clj/clojure/string.clj51
-rw-r--r--test/clojure/test_clojure/string.clj12
2 files changed, 32 insertions, 31 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))
+
+
diff --git a/test/clojure/test_clojure/string.clj b/test/clojure/test_clojure/string.clj
index 739f7bb4..ce557bbc 100644
--- a/test/clojure/test_clojure/string.clj
+++ b/test/clojure/test_clojure/string.clj
@@ -41,13 +41,13 @@
(is (= "Foobar" (s/capitalize "foobar")))
(is (= "Foobar" (s/capitalize "FOOBAR"))))
-(deftest t-ltrim
- (is (= "foo " (s/ltrim " foo ")))
- (is (= "" (s/ltrim " "))))
+(deftest t-triml
+ (is (= "foo " (s/triml " foo ")))
+ (is (= "" (s/triml " "))))
-(deftest t-rtrim
- (is (= " foo" (s/rtrim " foo ")))
- (is (= "" (s/rtrim " "))))
+(deftest t-trimr
+ (is (= " foo" (s/trimr " foo ")))
+ (is (= "" (s/trimr " "))))
(deftest t-trim
(is (= "foo" (s/trim " foo \r\n"))))