regular expressions in a simple way: VerbalExpressions

Surfing to find new things, i found this important library.. amd i thought:
‘how is possible survive to regular expressions, without using this VerbalExpressions???

If you worked with regex, when you read the initial example.. the smile open your face…

 

VerbalExpression testRegex = VerbalExpression.regex()
                                                .startOfLine().then("http").maybe("s")
	           				.then("://")
	           				.maybe("www.").anythingBut(" ")
	           				.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(); // Outputs the regex used:
                      // ^(?:http)(?:s)?(?:\:\/\/)(?:www\.)?(?:[^\ ]*)$

Is it very very fantastic?

https://github.com/VerbalExpressions/JavaVerbalExpressions

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *