RegRex is a Java library that makes creating regular expressions easier. Instead of manually crafting complex regex strings, RegRex allows you to build expressions in a modular and readable way.
import regrex.domain.RexRegEx;
public class Example {
public static void main(String[] args) {
RexRegEx builder = new RexRegEx();
String regex = builder
.followedFrom(RexRegEx.anyDigit())
.followedFrom(RexRegEx.anyLetterFromSet("abc"))
.getRegExString();
System.out.println(regex); // Prints, for example, "\d[abc]"
}
}-
noneToInfinitelyTimes(String expression)Returns the expression that repeats the pattern zero to infinitely many times (*). -
oneToInfinitelyTimes(String expression)Returns the expression that repeats the pattern at least once (+). -
noneOrOneTime(String expression)Returns the expression that repeats the pattern zero or once (?). -
xTimes(String expression, int numberOfTimesToOccur)Returns the expression that repeats the pattern exactlynumberOfTimesToOccurtimes ({n}). -
XToYTimes(String expression, int minNumberOfTimesToOccur, int maxNumberOfTimesToOccur)Returns the expression that repeats the pattern betweenminandmaxtimes ({min,max}).
-
anyCharacter()Returns the expression that represents any character (.). -
anyDigit()Returns the expression that represents a digit (\d). -
noDigit()Returns the expression that represents a non-digit character (\D). -
whitespaceCharacter()Returns the expression that represents a whitespace character (\s). -
noWhitespaceCharacter()Returns the expression that represents a non-whitespace character (\S). -
wordCharacter()Returns the expression that represents a word character (\w). -
noWordCharacter()Returns the expression that represents a non-word character (\W). -
wordBoundary()Returns the expression that represents a word boundary (\b).
-
anyLetterFromSet(...)Returns the expression that represents any character from the specified set ([...]). SupportsString,List<String>,Set<Character>,Character..., andString.... -
noLetterFromSet(...)Returns the expression that represents any character that is not in the specified set ([^...]). Supports the same parameters asanyLetterFromSet.
-
group(...)Returns the expression that groups the specified elements ((...)). SupportsString,List<String>,Set<Character>, andString.... -
charSequence(String charSequence)Returns the expression that represents the exact character sequence. -
or(String argumentA, String argumentB)Returns the expression that accepts eitherargumentAorargumentB(|).
lineEnd()Returns the expression that marks the end of a line ($).
-
followedFrom(String expression)Appends the specified expression to the current pattern. -
notFollowedFrom(String expression)Adds a negative lookahead condition that ensures that the specified expression does not follow. -
getRegExString()Returns the currently constructed regular expression as aString.
-
eMailRegExRegular expression for validating email addresses. -
internationalTelephoneNumberRegExRegular expression for validating international phone numbers. -
urlRegExRegular expression for validating URLs. -
iPv4RegExRegular expression for validating IPv4 addresses. -
userNameRegExRegular expression for validating usernames. -
weakPasswordRegExRegular expression for validating weak passwords. -
macAdressRegExRegular expression for validating MAC addresses.
-
upperCaseLettersContains all uppercase letters of the alphabet. -
lowerCaseLettersContains all lowercase letters of the alphabet. -
specialCharactersContains a selection of special characters. -
numbersContains the numbers 0 to 9.
For detailed instructions, usage examples, and interactive code snippets, please visit our documentation website.
This project is licensed under the MIT License. For more information, see the LICENSE file.