public class RegexUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
findMatches(String string,
Pattern pattern)
Returns the matches found for a given string using regular expression.
|
static List<String> |
findMatches(String string,
String regex)
Returns the matches found for a given string using regular expression.
|
static List<String> |
findUnixLikeVariablePlaceholders(String string)
Method that finds the place-holders in Unix-like pattern for the given string.
|
static String |
firstMatch(String string,
Pattern pattern)
Returns the first match found for a given string using regular expression.
|
static String |
firstMatch(String string,
String regex)
Returns the first match found for a given string using regular expression.
|
static boolean |
hasUnixLikeVariablePlaceholders(String string)
Checks if the string has place-holders for variables in Unix-like pattern.
|
static boolean |
matches(String string,
Pattern pattern)
Returns true if the given string contains at least one match of the given pattern.
|
static boolean |
matches(String string,
String regex)
Returns true if the given string contains at least one match of the given regular
expression.
|
static String |
replaceMatches(String string,
String regex,
String replacement)
Replaces all matches found for the given regular expression with a replacement string.
|
static String |
replacePlaceholdersWithVariables(String string,
Map<String,Object> variables)
Method to replace place-holders with variables.
|
public static boolean matches(String string, Pattern pattern)
string - The string to be matchedpattern - The pattern to usetrue if matches, otherwise falsepublic static boolean matches(String string, String regex)
string - The string to be matchedregex - The regular expression to usetrue if matches, otherwise falsepublic static List<String> findMatches(String string, Pattern pattern)
string - The string to be matchedpattern - The pattern to usepublic static List<String> findMatches(String string, String regex)
string - The string to be matchedregex - The regular expression to usepublic static String firstMatch(String string, Pattern pattern)
string - The string to be matchedpattern - The pattern to usepublic static String firstMatch(String string, String regex)
string - The string to be matchedregex - The regular expression to usepublic static String replaceMatches(String string, String regex, String replacement)
string - The string to be matchedregex - The regular expression to usereplacement - The replacement stringpublic static boolean hasUnixLikeVariablePlaceholders(String string)
string - the string to be replacedpublic static List<String> findUnixLikeVariablePlaceholders(String string)
string - the string to be used to find place-holderspublic static String replacePlaceholdersWithVariables(String string, Map<String,Object> variables)
string - The given string to be replacedvariables - A map containing place-holder names and value that will be used in
replacementCopyright © 2023. All rights reserved.