The doc string for re-matches says that it
uses java.util.regex.Matcher.matches().  The Java doc page for the class
java.util.regex.Matcher [1] says "The matches
<https://docs.oracle.com/javase/8/docs/api/java/util/regex/Matcher.html#matches-->
method
attempts to match the entire input sequence against the pattern."

The doc string for re-find says that it
uses java.util.regex.Matcher.find().  On [1] you can find the statement "
The find
<https://docs.oracle.com/javase/8/docs/api/java/util/regex/Matcher.html#find-->
method
scans the input sequence looking for the next subsequence that matches the
pattern."

I haven't dug into your regex and string in detail, but most likely what is
happening is that the regex matches part of the string, but it doesn't
match the _entire_ string.

Andy

[1] https://docs.oracle.com/javase/8/docs/api/java/util/regex/Matcher.html




On Tue, Dec 4, 2018 at 11:16 AM Randy J. Ray <rj...@blackperl.com> wrote:

> I must be doing something wrong here, but I cannot figure this out.
>
> The following results in "nil" from re-matches:
>
> (re-matches #"\[((\d+)-(\d+)-(\d+) (\d\d):(\d\d))\] (.*)" "[1518-05-27
> 00:42] falls asleep\n")
>
> This, however, properly matches the line and produces the backreferences:
>
> (re-find (re-matcher #"\[((\d+)-(\d+)-(\d+) (\d\d):(\d\d))\] (.*)"
> "[1518-05-27 00:42] falls asleep\n"))
>
> I've used re-matches many times, but this has me stumped. This is behaving
> this way on both 1.8.0 and 1.9.0.
>
> Randy
> --
> Randy J. Ray - randy.j....@gmail.com - twitter.com/rjray
> Silicon Valley Scale Modelers: http://www.svsm.org
> Sunnyvale, CA
>
> --
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to