Skip to content

suchintan/JavaVerbalExpressions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status JavaVerbalExpressions

VerbalExpressions is a Java library that helps to construct difficult regular expressions - ported from the wonderful JSVerbalExpressions.

##Examples

VerbalExpression testRegex = new VerbalExpression.Builder()
	           					 .startOfLine()
	           					 .then("http")
	           					 .maybe("s")
	           					 .then("://")
	           					 .maybe("www.")
	           					 .anythingButNot(" ")
	           					 .endOfLine()
	           					 .build();

// Create an example URL
String url = "https://www.google.com";

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

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

VerbalExpression testRegex = new VerbalExpression.Builder()
                                 .startOfLine()
                                 .then("abc")
                                 .or("def")
                                 .build();

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

Other implementations

You can view all implementations on VerbalExpressions.github.io

About

Java regular expressions made easy.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published