Re: Comparing Regular Expression pattens for equality?

2014-02-27 Thread Thomas
Thanks guys, Shame that it doesn't work that way. I've worked around it as suggested below. Thomas -- 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

Comparing Regular Expression pattens for equality?

2014-02-26 Thread Thomas
Hi Everyone, I am creating some regular expressions programmatically with re-pattern. In order to avoid creating the same regex pattern again I want to check if it already exists. But comparing regex pattern doesn't seem to be work: user= (= #test #test) false user= (identical? #test #test)

Re: Comparing Regular Expression pattens for equality?

2014-02-26 Thread Michael Gardner
You can compare the output of the .pattern or .toString methods if all you care about is finding regexes made from the exact same patterns. There's no simple way to detect equivalent regexes made from different patterns, though. As for why = doesn't do this, you'd have to talk to the Java folks

Re: Comparing Regular Expression pattens for equality?

2014-02-26 Thread Jan Herich
Clojure re-uses java.util.regex.Pattern objects. This object doesn't override equals method, so object references are always compared. But you can easily get pattern string from compiled pattern and then compare just them: user= (= (.pattern #test) (.pattern #test)) true Dňa streda, 26.