Visit GitHub RepoUtils


release Maven Central Coverage Status

VerbalExpressions is a Java library that helps to construct difficult regular expressions.

Getting Started

Maven Dependency:


You can use SNAPSHOT dependency with adding to pom.xml:



VerbalExpression testRegex = VerbalExpression.regex()
	           				.maybe("www.").anythingBut(" ")

// Create an example URL
String url = "";

// Use VerbalExpression's testExact() method to test if the entire string matches the regex
testRegex.testExact(url); //True

testRegex.toString(); // Outputs the regex used:
                      // ^(?:http)(?:s)?(?:\:\/\/)(?:www\.)?(?:[^\ ]*)$
VerbalExpression testRegex = VerbalExpression.regex()

String testString = "defzzz";

//Use VerbalExpression's test() method to test if parts if the string match the regex
testRegex.test(testString);       // true
testRegex.testExact(testString);  // false
testRegex.getText(testString);    // returns: def

Builder can be cloned:

VerbalExpression regex = regex(regex().anything().addModifier('i')).endOfLine().build();

Or can be used in another regex:

VerbalExpression.Builder digits = regex().capt().digit().oneOrMore().endCapt().tab();
VerbalExpression regex2 = regex().add(digits).add(digits).build();

Feel free to use any predefined char groups:


Define captures:

String text = "aaabcd";
VerbalExpression regex = regex()

regex.getText(text)     // returns "abcd"
regex.getText(text, 1)  // returns "b"

More complex examples

Other implementations

You can view all implementations on

[ Javascript - PHP - Python - C# - Objective-C - Ruby - Groovy - Haskell - C++ - ... (moarr) ]

Project released with travis

With help of this tutorial:

Become a better Android Developer
Millions of developers are learning at MindOrks

Online Training Program

Featured Blogs

Our Team

MindOrks is Certainly one of the best online blog to stay on top of all the Android development news, coding and design patterns. Finally a blog I can count on to keep myself updated with latest and greatest things happening in Android world.

Vipul Shah
Android Developer

Become Pro in Android by watching videos