Skip to content

Commit

Permalink
[LANG-1238] Add RegexUtils class instead of overloadinh methods in
Browse files Browse the repository at this point in the history
StringUtils that take a regex to take precompiled Pattern. Use 120 chars
per line.
  • Loading branch information
garydgregory committed May 17, 2018
1 parent 54acb6e commit bd4066e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/test/java/org/apache/commons/lang3/RegExUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import org.junit.Test;

/**
* Unit tests for methods of {@link org.apache.commons.lang3.RegExUtils}
* which been moved to their own test classes.
* Unit tests for methods of {@link org.apache.commons.lang3.RegExUtils} which been moved to their own test classes.
*/
public class RegExUtilsTest {

Expand Down Expand Up @@ -173,8 +172,7 @@ public void testReplaceAll_StringStringString() {
assertEquals("ABC___123", RegExUtils.replaceAll("ABCabc123", "[a-z]", "_"));
assertEquals("ABC_123", RegExUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", "_"));
assertEquals("ABC123", RegExUtils.replaceAll("ABCabc123", "[^A-Z0-9]+", ""));
assertEquals("Lorem_ipsum_dolor_sit",
RegExUtils.replaceAll("Lorem ipsum dolor sit", "( +)([a-z]+)", "_$2"));
assertEquals("Lorem_ipsum_dolor_sit", RegExUtils.replaceAll("Lorem ipsum dolor sit", "( +)([a-z]+)", "_$2"));

try {
RegExUtils.replaceAll("any", "{badRegexSyntax}", "");
Expand Down Expand Up @@ -203,7 +201,7 @@ public void testReplaceFirst_StringPatternString() {
assertEquals("ABC_123abc", RegExUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), "_"));
assertEquals("ABC123abc", RegExUtils.replaceFirst("ABCabc123abc", Pattern.compile("[^A-Z0-9]+"), ""));
assertEquals("Lorem_ipsum dolor sit",
RegExUtils.replaceFirst("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
RegExUtils.replaceFirst("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2"));
}

@Test
Expand Down

0 comments on commit bd4066e

Please sign in to comment.