Look at clojure.contrib.str-utils2/replace. It accepts a function -- the fn will be called on each match, and its return value will be inserted into the result string.
But that may not be quite what you want. If you want true string generation, you'd need a template library. -SS On Jul 29, 9:49 am, Rowdy Rednose <rowdy.redn...@gmx.net> wrote: > Does anybody know an elegant way to have a regex pattern with > capturing groups like in this simple example: > > user=> (def pat #"^foo=([^;]*);bar=([^;]*);$") > #'user/pat > > user=> (re-seq pat "foo=F0o;bar=bAr;") > (["foo=F0o;bar=bAr;" "F0o" "bAr"]) > > And reuse that pattern to generate a text that replaces the groups > like this: > > user=> (re-gen pat "foo-gen" "bar-gen") > "foo=foo-gen;bar=bar-gen" > > Actually, I wouldn't mind if the common representation was not a > Pattern, but something else, as long as I can use just one > representation as input and can do both matching and generating with > it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---