I was just trying out str-utils2 when Stuart posted. Here's an example; (require '[clojure.contrib.str-utils2 :as s])
(s/replace "hello Jung" #"hello (\S+)" #(str "hello, how are you "(% 1))) "hello, how are you Jung" Rgds, Adrian. On Tue, Sep 29, 2009 at 4:58 PM, Stuart Sierra <the.stuart.sie...@gmail.com> wrote: > > Hi Jung, > > Look at clojure.contrib.str-utils2/replace -- you can pass a function > as the replacement parameter and make any substitutions you want. > > -SS > > > On Sep 28, 6:51 pm, Jung Ko <koj...@gmail.com> wrote: >> Does anyone know how I can replace a string with back-reference? I'd >> like something like this: >> >> (use clojure.contrib.str-utils) >> (re-sub #"hello (\S+)" ", how are you \1?" "hello Jung") >> => "hello, how are you Jung?" >> >> Basically I need the back reference \1 to evaluate to "Jung" in the >> above case. Is there an easy way to do this? >> >> Thanks, >> Jung > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---