On Jun 21, 2009, at 4:34 PM, Alpinweis wrote:

I am trying some regex in Clojure and I have problems using regex
literals.

Don't know why the following doesn't seem to work:

user=> (re-seq #"\\W+" "the quick brown fox")
()
user=> (re-seq #"\\w+" "the quick brown fox")
()
user=> (re-seq #"\\s" "the quick brown fox")
()
user=> (re-seq #"\\S" "the quick brown fox")
()

The string that forms the regex literal is not subject to the usual string escaping. You don't need to (and should not) double the backslash.

Is there any detailed info on using regex literals in Clojure?

It appears the official doc at http://clojure.org/reader doesn't make this clear. It would be good to fix that.

Here's some info:

        http://items.sjbach.com/406/clojures-new-regex-syntax

And the Google search:

        http://www.google.com/search?q=clojure+regex+literal

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to