java.lang.Object
io.github.astrapi69.regex.RegExExtensions
Utility class for the use with regular expressions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Regular expression class for the valid characters in a filename.static final String
Regular expression for the valid characters in an email.static final String
Regular expression for the valid characters in a phone number.static final String
Constant for the wildcard asterisk "*".static final String
Regular expression for many characters in the filename.static final String
Regular expression for exactly on character in the filename.static final String
Constant for the wildcard interrogation mark "?". -
Method Summary
Modifier and TypeMethodDescriptionstatic int
countMatches
(String regexPattern, String text) Count how many times the given text is matching and returns the result.static boolean
isMatching
(String regexPattern, String text) Checks if the given regular expression pattern is matching with the given text.static String
replaceWildcardsWithRE
(String queryString) Replaces the normal wildcards in the given String with the corresponding regular expression wildcards.static String
wildcardCriterionSQL
(String query) Replaces the query with the wildcards asterisk "*" and interrogation mark "?"
-
Field Details
-
VALID_CHARS_IN_FILENAME
Regular expression class for the valid characters in a filename. Current value:"[a-zA-Z0-9._-]"- See Also:
-
VALID_EMAIL
Regular expression for the valid characters in an email. Current value:"([\w\-\.\+_]+@[\w\-\._]{2,}\.+[\w]{2,4})?"- See Also:
-
VALID_PHONE
Regular expression for the valid characters in a phone number. Current value:"^[a-zA-Z .,;:/\\-]*[ ]*[(]{0,1}[ ]*[+]{0,1}[ ]*[0-9]{0,2}[ ]*[)]{0,1}[ ]*[0-9]*[ ]*[/\\-]{0,1}[ ]*[ ]*[0-9]*[ ]*[a-zA-Z .,;:\\/-]*$"- See Also:
-
WILDCARD_ASTERISK
Constant for the wildcard asterisk "*". Current value:"*"- See Also:
-
WILDCARD_MANYCHARS_RE
Regular expression for many characters in the filename. Current value:".*"- See Also:
-
WILDCARD_ONECHAR_RE
Regular expression for exactly on character in the filename. Current value:"[a-zA-Z0-9._-]{1}"- See Also:
-
WILDCARD_QUESTION_MARK
Constant for the wildcard interrogation mark "?". Current value:"?"- See Also:
-
-
Method Details
-
countMatches
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
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
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
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 "_".
-