(def matcher (doto (re-matcher #"(\d{2})\/(\d{2})\/(\d{4})" "12/02/1975 ")
(.find)))
(.groupCount matcher) ;; 3
(.group matcher 3) ;; "1975"
(nth matcher 3) ;; "1975"
(nth matcher 3 nil) ;; nil, but "1975" expected
seems like a bug in (nth <matcher-instance> <index> <not-found>)
implementation for Matcher
.
- from the docs of .groupCount: "Group zero denotes the entire pattern by convention. It is not included in this count."
- the check in RT.java in the
nth
implementation checks to make sure n < m.groupCount()
- the check should be for
n <= m.groupCount()