Skip to content
Browse files

minor fixes to #359:

  - add clojure.string to build,
  - make replace,replace-first use CharSequence in same way

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
1 parent 8c8fc40 commit fc8af8cb67b2240dd3fd0f391fcd1f718f3d90e3 @stuarthalloway stuarthalloway committed Jun 2, 2010
Showing with 5 additions and 2 deletions.
  1. +1 −0 build.xml
  2. +3 −2 src/clj/clojure/string.clj
  3. +1 −0 test/clojure/test_clojure/string.clj
View
1 build.xml
@@ -111,6 +111,7 @@
<arg value="clojure.java.javadoc"/>
<arg value="clojure.java.shell"/>
<arg value="clojure.java.browse-ui"/>
+ <arg value="clojure.string"/>
</java>
</target>
View
5 src/clj/clojure/string.clj
@@ -64,8 +64,9 @@ clojure.string adheres to the following design principles:
(cond
(instance? Character match) (.replace s ^Character match ^Character replacement)
(instance? CharSequence match) (.replace s ^CharSequence match ^CharSequence replacement)
- (instance? Pattern match) (if (string? replacement)
- (.replaceAll (re-matcher ^Pattern match s) ^CharSequence replacement)
+ (instance? Pattern match) (if (instance? CharSequence replacement)
+ (.replaceAll (re-matcher ^Pattern match s)
+ (.toString replacement))
(replace-by s match replacement))
:else (throw (IllegalArgumentException. (str "Invalid match arg: " match))))))
View
1 test/clojure/test_clojure/string.clj
@@ -81,6 +81,7 @@
"paz" s/reverse ["zap"]
"foo:bar" s/replace ["foo-bar" \- \:]
"ABC" s/replace ["abc" #"\w" s/upper-case]
+ "faa" s/replace ["foo" #"o" (StringBuffer. "a")]
"baz::quux" s/replace-first ["baz--quux" #"--" "::"]
"baz::quux" s/replace-first ["baz--quux" (StringBuffer. "--") (StringBuffer. "::")]
"zim-zam" s/replace-first ["zim zam" #" " (StringBuffer. "-")]

0 comments on commit fc8af8c

Please sign in to comment.
Something went wrong with that request. Please try again.