VerbalExpressions/DartVerbalExpressions

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Pub Package Build Status Coverage Status Github Issues

verbal_expressions

A library for Dart developers that helps to construct difficult regular expressions.

Dart package info is here: https://pub.dartlang.org/packages/verbal_expressions

Quick start
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"
Examples

More examples are in example file

Features and bugs

Please find feature requests and bugs at the issue tracker.

Other implementations

You can view all implementations on VerbalExpressions.github.io

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.