Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cljs.reader/read-string and regular expression

Is this a bug or by design? It seems like CLJS reader cannot read regular expressions:

(cljs.reader/read-string (pr-str #"a"))

error {:message "EOF while reading.", :data {:type :reader-exception, :ex-kind :eof}}

Clojurescript v1.9.908

UPDATE: It works with v1.9.229 and Clojure 1.8.0. I'll try to see which version broke that...

like image 417
Blacksad Avatar asked Jul 08 '26 22:07

Blacksad


1 Answers

cljs.reader/read-string only reads data in edn format & clojure regular expression #"..." syntax is not part of edn specification. (see http://edn-format.org)

https://cljs.github.io/api/cljs.reader/read-string

Reads one object from the string s. Returns nil when s is nil or empty.

Reads data in the edn format (subset of Clojure data): http://edn-format.org

opts is a map as per cljs.tools.reader.edn/read

like image 176
mavbozo Avatar answered Jul 11 '26 14:07

mavbozo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!