(The examples from the REPL still apply.)
On 1 April 2013 10:15, Michał Marczyk <michal.marc...@gmail.com> wrote: > Oh, wait, I posted the wrong function. Here's the one I meant: > > (defn pr-pattern [pat] > (pr (re-pattern (.replaceAll (re-matcher (re-pattern "\n") > (.toString pat)) > "\\\\n")))) > > > On 1 April 2013 10:00, Michał Marczyk <michal.marc...@gmail.com> wrote: >> On 1 April 2013 07:53, Mark Engelberg <mark.engelb...@gmail.com> wrote: >>> Yeah, my goal is simply to get (re-pattern #"a\nb") to print (or more >>> precisely, pr) as #"a\nb" without affecting the semantics of printing other >>> regular expressions, but that seems to be impossible to achieve. Sigh... >> >> Could you just preprocess the strings passed to re-pattern (or >> patterns if you're getting those as input) to replace literal newlines >> with escape sequences? I'm assuming you don't care about ?x given the >> result you wish to achieve. >> >> Otherwise, I haven't done much testing on this, but perhaps you could >> see whether it would work for you: >> >> (defn pr-pattern [pat] >> (print (str "#\"" >> (.replaceAll (re-matcher (re-pattern "\n") >> (.toString pat)) >> "\\\\n") >> "\""))) >> >> user=> (pr-pattern (re-pattern "a\nb")) >> #"a\nb"nil >> user=> (pr-pattern #"a\nb") >> #"a\nb"nil >> >> (The nils are of course the return values. There are indeed four >> backslashes in the replacement string literal, since >> Matcher.replaceAll has its own escaping for $ (captured subsequence >> reference when not escaped) and \.) >> >> Cheers, >> Michał -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.