Package io.github.astrapi69.regex
Class RegExExtensions
- java.lang.Object
-
- io.github.astrapi69.regex.RegExExtensions
-
public final class RegExExtensions extends java.lang.Object
Utility class for the use with regular expressions.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
VALID_CHARS_IN_FILENAME
Regular expression class for the valid characters in a filename.static java.lang.String
VALID_EMAIL
static java.lang.String
VALID_PHONE
static java.lang.String
WILDCARD_ASTERISK
Constant for the wildcard asterisk "*".static java.lang.String
WILDCARD_MANYCHARS_RE
Regular expression for many characters in the filename.static java.lang.String
WILDCARD_ONECHAR_RE
Regular expression for exactly on character in the filename.static java.lang.String
WILDCARD_QUESTION_MARK
Constant for the wildcard interrogation mark "?".
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
countMatches(java.lang.String regexPattern, java.lang.String text)
Count how many times the given text is matching and returns the result.static boolean
isMatching(java.lang.String regexPattern, java.lang.String text)
Checks if the given regular expression pattern is matching with the given text.static java.lang.String
replaceWildcardsWithRE(java.lang.String queryString)
Replaces the normal wildcards in the given String with the corresponding regular expression wildcards.static java.lang.String
wildcardCriterionSQL(java.lang.String query)
Replaces the query with the wildcards asterisk "*" and interrogation mark "?"
-
-
-
Field Detail
-
VALID_CHARS_IN_FILENAME
public static final java.lang.String VALID_CHARS_IN_FILENAME
Regular expression class for the valid characters in a filename. Current value:"[a-zA-Z0-9._-]"- See Also:
- Constant Field Values
-
VALID_EMAIL
public static final java.lang.String VALID_EMAIL
- See Also:
- Constant Field Values
-
VALID_PHONE
public static final java.lang.String VALID_PHONE
- See Also:
- Constant Field Values
-
WILDCARD_ASTERISK
public static final java.lang.String WILDCARD_ASTERISK
Constant for the wildcard asterisk "*". Current value:"*"- See Also:
- Constant Field Values
-
WILDCARD_MANYCHARS_RE
public static final java.lang.String WILDCARD_MANYCHARS_RE
Regular expression for many characters in the filename. Current value:".*"- See Also:
- Constant Field Values
-
WILDCARD_ONECHAR_RE
public static final java.lang.String WILDCARD_ONECHAR_RE
Regular expression for exactly on character in the filename. Current value:"[a-zA-Z0-9._-]{1}"- See Also:
- Constant Field Values
-
WILDCARD_QUESTION_MARK
public static final java.lang.String WILDCARD_QUESTION_MARK
Constant for the wildcard interrogation mark "?". Current value:"?"- See Also:
- Constant Field Values
-
-
Method Detail
-
countMatches
public static int countMatches(java.lang.String regexPattern, java.lang.String text)
Count how many times the given text is matching and returns the result.- Parameters:
regexPattern
- the regular expression patterntext
- the text to check if it matches- Returns:
- the count of how many times the given text is matching
-
isMatching
public static boolean isMatching(java.lang.String regexPattern, java.lang.String text)
Checks if the given regular expression pattern is matching with the given text.- Parameters:
regexPattern
- the regular expression patterntext
- the text to check if it matches- Returns:
- true if the given text is matching otherwise false
-
replaceWildcardsWithRE
public static java.lang.String replaceWildcardsWithRE(java.lang.String queryString)
Replaces the normal wildcards in the given String with the corresponding regular expression wildcards.- Parameters:
queryString
- The String to format.- Returns:
- Returns the formatted String as a regular expression for search.
-
wildcardCriterionSQL
public static java.lang.String wildcardCriterionSQL(java.lang.String query)
Replaces the query with the wildcards asterisk "*" and interrogation mark "?" with the corresponding wildcard from SQL.- Parameters:
query
- The String to replace the wildcards.- Returns:
- The String with the new wildcards from SQL "%" and "_".
-
-