<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent activity in Regex</title>
<link>https://ask.clojure.org/index.php/activity/clojure/regex</link>
<description></description>
<item>
<title>Answered: Could re-pattern be extended to allow flags?</title>
<link>https://ask.clojure.org/index.php/13894/could-re-pattern-be-extended-to-allow-flags?show=13897#a13897</link>
<description>&lt;p&gt;Logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2854&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2854&lt;/a&gt;&lt;/p&gt;
</description>
<category>Regex</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13894/could-re-pattern-be-extended-to-allow-flags?show=13897#a13897</guid>
<pubDate>Wed, 22 May 2024 19:20:39 +0000</pubDate>
</item>
<item>
<title>Closed: Off by one error in `(nth &lt;java.util.regex.Matcher-instance&gt; &lt;index&gt; &lt;not-found&gt;)`</title>
<link>https://ask.clojure.org/index.php/9740/off-one-error-nth-java-util-regex-matcher-instance-index-found?show=9740#q9740</link>
<description>&lt;pre&gt;&lt;code&gt;(def matcher (doto (re-matcher #&quot;(\d{2})\/(\d{2})\/(\d{4})&quot; &quot;12/02/1975 &quot;)
               (.find)))
(.groupCount matcher) ;; 3
(.group matcher 3) ;; &quot;1975&quot;
(nth matcher 3) ;; &quot;1975&quot;
(nth matcher 3 nil) ;; nil, but &quot;1975&quot; expected
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;seems like a bug in &lt;code&gt;(nth &amp;lt;matcher-instance&amp;gt; &amp;lt;index&amp;gt; &amp;lt;not-found&amp;gt;)&lt;/code&gt; implementation for &lt;code&gt;Matcher&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;from the docs of &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#groupCount()&quot;&gt;.groupCount&lt;/a&gt;: &quot;Group zero denotes the entire pattern by convention. It is not included in this count.&quot;&lt;/li&gt;
&lt;li&gt;the check in &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/d07ef175c700329f7afbef8770332b6247a34a49/src/jvm/clojure/lang/RT.java#L968&quot;&gt;RT.java&lt;/a&gt; in the &lt;code&gt;nth&lt;/code&gt; implementation checks to make sure &lt;code&gt;n &amp;lt; m.groupCount()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;the check should be for &lt;code&gt;n &amp;lt;= m.groupCount()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Regex</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9740/off-one-error-nth-java-util-regex-matcher-instance-index-found?show=9740#q9740</guid>
<pubDate>Mon, 18 Jan 2021 16:10:49 +0000</pubDate>
</item>
</channel>
</rss>