If you print it as a string, then want to read it back in and convert back to a regex, you must read it as a string, then call re-pattern on it. That should preserve the original meaning.
Printing it as a string, and trying to read it as a regex by prepending it directly with # before the " of the string, would definitely change the meaning of the regex in the case you mention, and many many others. Andy On Sun, Mar 31, 2013 at 10:33 PM, Mark Engelberg <mark.engelb...@gmail.com>wrote: > On Sat, Mar 30, 2013 at 11:33 AM, Mark Engelberg <mark.engelb...@gmail.com > > wrote: > >> On Thu, Mar 28, 2013 at 6:36 PM, Andy Fingerhut <andy.finger...@gmail.com >> > wrote: >> >>> (defn print-regex-my-way [re] >>> (print "#regex ") >>> (pr (str re))) >>> >>> That might be closer to what you want. >>> >> >> Yes. That does the trick. That extra level of converting the regular >> expression to a string does the trick because pr "does the right thing" >> with strings, but not with regexes. I'd classify pr's different behavior >> on regexes as a bug, but this is an effective workaround. >> > > I found a deficiency with the trick of converting the regex to a string > for printing. > > Consider: > (print-regex-my-way #"\s") > which will print as > #regex "\\s" > > The extra \ changes the meaning of the regular expression. > > > > > > -- > -- > 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. > > > -- -- 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.