Question

I would like to do something like that:

(def my_regex #"[1-9]")
(extract-string my-regex)
=> "[1-9]"

Is it possible in clojure?

Was it helpful?

Solution

It's easy:

(.toString my_regex)

Actually, all Java (and Clojure) objects have .toString method returning its string representation.

There is also a str function in Clojure, which calls .toString on each of its arguments and concatenates results:

 (str my_regex)

So, it's doing the same thing, but it's pure Clojure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top