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 ignoring case, putting (?i) at the beginning of the regex worked for me. (re-find) should give you $1 just fine. user=> (require '[clojure.string :as str]) nil user=> (str/lower-case (re-find #"(?i)mon|tue|wed|thu|fri|sat|sun" "asdf MON tue")) "mon" Hope this helps! On Jan 13, 7:35 pm, Alex Baranosky <alexander.barano...@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 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 has been: > > (defonce date-regex #"^\s*(\d{4})\s+(\d{1,2})\s+(\d{1,2})") > (re-find date-regex line) > > but I'm not sure how to access $1, $2, and $3 > > Another example I'd like to convert is this: > > DAYS_OF_WEEK_REGEX = /^\s*(#{Date::DAYS_OF_WEEK.join('|')})/i > > token =~ DAYS_OF_WEEK_REGEX > $1.downcase.to_sym > > Best attempt is: > > (defonce days-of-week-regex #"mon|tue|wed|thu|fri|sat|sun(?i)") > (re-find days-of-week-regex line) > > Here I'd love to know the syntax for ignore-case, along with how to access $1. > > Thanks, > Alex -- 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 moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en