So I am converting some Ruby code I have into CLojure for practice/fun and I
am having trouble finding info via Google.
I want to take something like this from Ruby and do it in Clojure:
DATE_REGEX = /^\s*(\d{4})\s+(\d{1,2})\s+(\d{1,2})/
token =~ DATE_REGEX
[$1, $2, $3]
So far my best guess
So I am converting some Ruby code I have into CLojure for practice/fun and I
am having trouble finding info via Google.
Clojure uses the same regex style as Java, so you'll need to search
for information on Java regexes rather than Clojure regexes.
--
You received this message because you are
Here is one way:
user= (import 'java.util.regex.Pattern)
java.util.regex.Pattern
user= (def p (Pattern/compile mon|tue|wed|thu|fri|sat|sun
Pattern/CASE_INSENSITIVE))
#'user/p
user= (re-find p I have a dentist appoint on Monday morning, so you'll
need to take the kids to school.)
Mon
Bill
On
i think you want to do something like this:
(let [_ year month day] (re-find date-regex line))
On Thu, Jan 13, 2011 at 8:50 PM, Eric Lavigne lavigne.e...@gmail.com wrote:
So I am converting some Ruby code I have into CLojure for practice/fun and I
am having trouble finding info via Google.
I see. So I may have to use some kind of clunky syntax instead of a nice
$1, $2, $3 syntax. I can handle that I guess :)
Thanks.
--
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
A blog entry I read (and now can't find) mentioned being able to use syntax
like (?i) to do the ignore case.
--
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
For accessing groups in a match, you can use (re-matches). It will
always give the full match as the first element though:
user= (re-matches date-regex 2011 1 13)
[2011 1 13 2011 1 13]
So to replicate the Ruby code's behavior maybe you'll just want (rest
(re-matches date-regex line)).
For
On Thu, Jan 13, 2011 at 9:54 PM, Alex Baranosky
alexander.barano...@gmail.com wrote:
I see. So I may have to use some kind of clunky syntax instead of a nice
$1, $2, $3 syntax. I can handle that I guess :)
Hey, it's a Lisp! You can use almost any syntax you want. How about %1, %2, %3:
(defn
bah! good catch.
(let [[_ year month day]] (re-find date-regex line))
fixed!
On Thu, Jan 13, 2011 at 9:03 PM, Ken Wesson kwess...@gmail.com wrote:
On Thu, Jan 13, 2011 at 9:54 PM, Alex Baranosky
alexander.barano...@gmail.com wrote:
I see. So I may have to use some kind of clunky syntax
On Thu, Jan 13, 2011 at 10:22 PM, gaz jones gareth.e.jo...@gmail.com wrote:
bah! good catch.
(let [[_ year month day]] (re-find date-regex line))
fixed!
Oh, gaz. I'm so so sorry. :(
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this
lol oh noes! i should really stop doing this while watching 30rock...
On Thu, Jan 13, 2011 at 9:38 PM, Ken Wesson kwess...@gmail.com wrote:
On Thu, Jan 13, 2011 at 10:22 PM, gaz jones gareth.e.jo...@gmail.com wrote:
bah! good catch.
(let [[_ year month day]] (re-find date-regex line))
fixed!
11 matches
Mail list logo