Pregunta

I would like to do something like that:

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

Is it possible in clojure?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top