On Thu, Mar 28, 2013 at 6:16 PM, Andy Fingerhut <andy.finger...@gmail.com>wrote:
> When you say a "sane, readable way", do you mean human-readable, or > readable via clojure.core/read or clojure.core/read-string? > I meant human readable > > (defn print-regex-my-way [re] > (print "#regex \"" (str re) "\"")) > If you try this: (print-regex-my-way (re-pattern "a\nb")) you'll see that it still splits the line. > > Note: clojure.core/read and read-string are not safe to read from anything > but trusted data sources, so I wouldn't recommend it for anything except > files you write yourself, or code. See here for details if you are curious: > > http://clojuredocs.org/clojure_core/clojure.core/read > > Also note that the new clojure.edn/read and read-string, and the edn > readers in the tools.reader contrib library, don't read Java regexes. This > is by choice, I believe, with the reason given that regexes are not > portable across Java, JavaScript, etc. platforms. > > https://github.com/edn-format/edn/issues/26 > I'd like to know more about this, because I think I found a way around my problem using the built in read-string.to create a variation of re-pattern that handles "a\nb" as #"a\\nb" rather than the current way it handles it. (As you pointed out, I can't use edn/read-string because it doesn't support regexes). So what's wrong with this?: (defn safe-read-string [s] (binding [*read-eval* false] (read-string s))) -- -- 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.