This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 9bc57f7fe Add RegExUtils.dotAllMatcher(String, CharSequence) and
deprecate RegExUtils.dotAllMatcher(String, String)
9bc57f7fe is described below
commit 9bc57f7fed72c09468588f2f5ac5d5d503bc845c
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Jan 9 09:19:52 2025 -0500
Add RegExUtils.dotAllMatcher(String, CharSequence) and deprecate
RegExUtils.dotAllMatcher(String, String)
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/commons/lang3/RegExUtils.java | 15 +++++++++++++++
.../java/org/apache/commons/lang3/RegExUtilsTest.java | 6 ++++++
3 files changed, 22 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3e8d03abf..ba5729756 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -90,6 +90,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="add" dev="ggregory" due-to="Gary
Gregory">Add BasicThreadFactory.daemon().</action>
<action type="add" dev="ggregory" due-to="Gary
Gregory">Add ArrayUtils.startsWith.</action>
<action type="add" dev="ggregory" due-to="Gary
Gregory">Add Predicates.</action>
+ <action type="add" dev="ggregory" due-to="Gary
Gregory">Add RegExUtils.dotAllMatcher(String, CharSequence) and deprecate
RegExUtils.dotAllMatcher(String, String).</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary
Gregory, Dependabot">Bump org.apache.commons:commons-parent from 73 to 78
#1267, #1277, #1283, #1288, #1302.</action>
<action type="update" dev="ggregory" due-to="Gary
Gregory, Dependabot">[site] Bump org.codehaus.mojo:taglist-maven-plugin from
3.1.0 to 3.2.1 #1300.</action>
diff --git a/src/main/java/org/apache/commons/lang3/RegExUtils.java
b/src/main/java/org/apache/commons/lang3/RegExUtils.java
index c6c56cc96..824661919 100644
--- a/src/main/java/org/apache/commons/lang3/RegExUtils.java
+++ b/src/main/java/org/apache/commons/lang3/RegExUtils.java
@@ -38,6 +38,19 @@ public class RegExUtils {
return Pattern.compile(regex, Pattern.DOTALL);
}
+ /**
+ * Compiles the given regular expression into a pattern with the {@link
Pattern#DOTALL} flag, then creates a matcher that will match the given text
against
+ * this pattern.
+ *
+ * @param regex The expression to be compiled.
+ * @param text The character sequence to be matched.
+ * @return A new matcher for this pattern.
+ * @since 3.18.0
+ */
+ public static Matcher dotAllMatcher(final String regex, final CharSequence
text) {
+ return dotAll(regex).matcher(text);
+ }
+
/**
* Compiles the given regular expression into a pattern with the {@link
Pattern#DOTALL} flag, then creates a matcher that will match the given text
against
* this pattern.
@@ -46,7 +59,9 @@ public class RegExUtils {
* @param text The character sequence to be matched.
* @return A new matcher for this pattern.
* @since 3.13.0
+ * @deprecated Use {@link #dotAllMatcher(String, CharSequence)}.
*/
+ @Deprecated
public static Matcher dotAllMatcher(final String regex, final String text)
{
return dotAll(regex).matcher(text);
}
diff --git a/src/test/java/org/apache/commons/lang3/RegExUtilsTest.java
b/src/test/java/org/apache/commons/lang3/RegExUtilsTest.java
index 278f66892..913bd3e70 100644
--- a/src/test/java/org/apache/commons/lang3/RegExUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/RegExUtilsTest.java
@@ -38,6 +38,12 @@ public class RegExUtilsTest extends AbstractLangTest {
@Test
public void testDotAllMatcher() {
+ assertTrue(RegExUtils.dotAllMatcher("<A>.*</A>", (CharSequence)
"<A>\nxy\n</A>").matches());
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testDotAllMatcherDeprecated() {
assertTrue(RegExUtils.dotAllMatcher("<A>.*</A>",
"<A>\nxy\n</A>").matches());
}