Create regular expressions using chained methods.
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Put factory method back in. Sep 29, 2017
LICENSE.md Updated to es6 classes. Sep 29, 2017
README.md Put factory method back in. Sep 29, 2017
package.json Put factory method back in. Sep 29, 2017
regexpbuilder.js Add sticky flag. Jun 21, 2018

README.md

RegExpBuilder

RegExpBuilder integrates regular expressions into the programming language, thereby making them easy to read and maintain. Regular Expressions are created by using chained methods and variables such as arrays or strings.

Examples

Here are a couple of examples using Javascript:
var r = require('regexpbuilder');

Money

var regex = r
  .find("$")
  .min(1).digits()
  .then(".")
  .digit()
  .digit()
  .getRegExp();
  
regex.test("$10.00"); // true

Nested patterns

var pattern = r
  .min(1).of("p")
  .min(2).of("q");

var regex = r
  .exactly(2).like(pattern)
  .getRegExp();

regex.test("pqqpqq"); // true

API documentation

RegExpBuilder can represent literally every possible regular expression using methods such as either(), or(), behind(), asGroup() and so on. You can find the API documentation here.