[LANG-1238] Add RegexUtils class instead of overloadinh methods in

StringUtils that take a regex to take precompiled Pattern. Use 120 chars
per line.
This commit is contained in:
Gary Gregory 2018-05-17 17:18:45 -06:00
parent 54acb6e10f
commit bd4066eba8
1 changed files with 3 additions and 5 deletions

View File

@ -26,8 +26,7 @@ import java.util.regex.PatternSyntaxException;
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 {
@ -173,8 +172,7 @@ public class RegExUtilsTest {
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}", "");
@ -203,7 +201,7 @@ public class RegExUtilsTest {
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