Example usage for Java org.apache.commons.lang3 RegExUtils fields, constructors, methods, implement or subclass
The text is from its open source code.
String | removeAll(final String text, final Pattern regex) Removes each substring of the text String that matches the given regular expression pattern. This method is a null safe equivalent to:
A null reference passed to this method is a no-op. StringUtils.removeAll(null, *) = null StringUtils.removeAll("any", (Pattern) null) = "any" StringUtils.removeAll("any", Pattern.compile("")) = "any" StringUtils.removeAll("any", Pattern.compile(".*")) = "" StringUtils.removeAll("any", Pattern.compile(".+")) = "" StringUtils.removeAll("abc", Pattern.compile(".?")) = "" StringUtils.removeAll("A<__>\n<__>B", Pattern.compile("<.*>")) = "A\nB" StringUtils.removeAll("A<__>\n<__>B", Pattern.compile("(?s)<.*>")) = "AB" StringUtils.removeAll("A<__>\n<__>B", Pattern.compile("<.*>", Pattern.DOTALL)) = "AB" StringUtils.removeAll("ABCabc123abc", Pattern.compile("[a-z]")) = "ABC123" |
String | removeAll(final String text, final String regex) Removes each substring of the text String that matches the given regular expression. This method is a null safe equivalent to:
A null reference passed to this method is a no-op. Unlike in the #removePattern(String,String) method, the Pattern#DOTALL option is NOT automatically added. |
String | removePattern(final String text, final String regex) Removes each substring of the source String that matches the given regular expression using the DOTALL option. This call is a null safe equivalent to:
A null reference passed to this method is a no-op. StringUtils.removePattern(null, *) = null StringUtils.removePattern("any", (String) null) = "any" StringUtils.removePattern("A<__>\n<__>B", "<.*>") = "AB" StringUtils.removePattern("ABCabc123", "[a-z]") = "ABC123" |
String | replaceAll(final String text, final Pattern regex, final String replacement) Replaces each substring of the text String that matches the given regular expression pattern with the given replacement. This method is a null safe equivalent to:
A null reference passed to this method is a no-op. StringUtils.replaceAll(null, *, *) = null StringUtils.replaceAll("any", (Pattern) null, *) = "any" StringUtils.replaceAll("any", *, null) = "any" StringUtils.replaceAll("", Pattern.compile(""), "zzz") = "zzz" StringUtils.replaceAll("", Pattern.compile(".*"), "zzz") = "zzz" StringUtils.replaceAll("", Pattern.compile(".+"), "zzz") = "" StringUtils.replaceAll("abc", Pattern.compile(""), "ZZ") = "ZZaZZbZZcZZ" StringUtils.replaceAll("<__>\n<__>", Pattern.compile("<.*>"), "z") = "z\nz" StringUtils.replaceAll("<__>\n<__>", Pattern.compile("<.*>", Pattern.DOTALL), "z") = "z" StringUtils.replaceAll("<__>\n<__>", Pattern.compile("(?s)<.*>"), "z") = "z" StringUtils.replaceAll("ABCabc123", Pattern.compile("[a-z]"), "_") = "ABC___123" StringUtils.replaceAll("ABCabc123", Pattern.compile("[^A-Z0-9]+"), "_") = "ABC_123" StringUtils.replaceAll("ABCabc123", Pattern.compile("[^A-Z0-9]+"), "") = "ABC123" StringUtils.replaceAll("Lorem ipsum dolor sit", Pattern.compile("( +)([a-z]+)"), "_$2") = "Lorem_ipsum_dolor_sit" |
String | replaceAll(final String text, final String regex, final String replacement) Replaces each substring of the text String that matches the given regular expression with the given replacement. This method is a null safe equivalent to:
A null reference passed to this method is a no-op. Unlike in the #replacePattern(String,String,String) method, the Pattern#DOTALL option is NOT automatically added. |