Name: DartVerbalExpressions
Owner: VerbalExpressions
Description: Dart Regular expressions made easy.
Created: 2016-01-05 21:30:10.0
Updated: 2018-03-03 04:54:25.0
Pushed: 2017-01-14 12:11:13.0
Homepage: null
Size: 84
Language: Dart
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A library for Dart developers that helps to construct difficult regular expressions.
Dart package info is here: https://pub.dartlang.org/packages/verbal_expressions
r regex = new VerbalExpression()
.startOfLine()
.then("http").maybe("s")
.then("://")
.maybe("www.").anythingBut(" ")
.endOfLine();
Create an example URL
ring url = "https://www.google.com";
Use VerbalExpression's hasMatch() method to test if the entire string matches the regex
gex.hasMatch(url); //True
gex.toString(); // Outputs the regex used: ^http(s)?\\:\\/\\/(www\\.)?([^\\ ]*)\$
art
r regex = new VerbalExpression()..startOfLine()..then("abc")..or("def");
r testString = "defzzz";
Use VerbalExpression's hasMatch() method to test if parts if the string match the regex
gex.hasMatch(testString); // true
Feel free to use any predefined char groups:
r regex = new VerbalExpression()
..wordChar()..nonWordChar()
..space()..nonSpace()
..digit()..nonDigit();
Define captures:
r expression = new VerbalExpression()
.find("a")
.beginCapture()..find("b")..anything()..endCapture()
.then("cd");
gExp regex = expression.toRegExp();
r match = regex.firstMatch(text);
int(match.group(0)); // returns "abcd"
int(match.group(1)); // returns "b"
More examples are in example file
Please find feature requests and bugs at the issue tracker.
You can view all implementations on VerbalExpressions.github.io
[ Javascript - PHP - Python - C# - Objective-C - Ruby - Groovy - Haskell - C++ - … (moarr) ]