Thank you everyone for the tip. It works great. Using s/replace instead of re-sub makes the code much shorter and easier to read.
Thanks, Jung Ko On Tue, Sep 29, 2009 at 8:43 AM, Adrian Cuthbertson <[email protected]> wrote: > > 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 > <[email protected]> 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 <[email protected]> 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 [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
