GitXplorerGitXplorer
k

RegExpBuilder

public
4 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
e884f19b5f848d40ee89a43a259a96e272f3ee97

Update README

kkasium committed 7 years ago
Unverified
08e7af5d12645aae89ced4ca1757d4c021b93a74

Upload version 1.0.0

kkasium committed 8 years ago
Unverified
f4f2c1bddc5ca2ea6d4bb23554de0c2e662d957e

Upload version 0.6.0

kkasium committed 8 years ago
Unverified
ce599faa8766b6fa821acbdab717e283ff449b10

Update README.md

kkasium committed 8 years ago
Unverified
cf156df20eb700f1fee875a666d7e9d4689f9618

Upload version 0.5.0

kkasium committed 8 years ago
Unverified
48abc2a15c5676f62d1c36a3a1e8b14e93154880

Update README.md

kkasium committed 8 years ago

README

The README file for this repository.

RegExpBuilder

This little javascript libary helps you to write more readable regex code in javascript.

Installation

Just add the RegExpBuilder.js file from the js folder to your project.

##Compatibility This libary is compatible with everything which has ECMAScript5 implemented. The tests are using the promise feature of ECMAScript6.

##Examples

Floating Point Numbers

var builder = new RegExpBuilder();
builder.startLine().matchesFor("-+").zeroOrOneTimes()
 .and().matchesDigit().zeroOrMoreTimes()
 .and().matchesText(".").zeroOrOneTimes()
 .and().matchesDigit().oneOrMoreTimes()
 .beginGroup()
	.matchesFor("eE")
	.and().matchesFor("-+").zeroOrOneTimes()
	.matchesDigit().oneOrMoreTimes()
 .endGroup().oneOrMoreTimes().endLine();
 var regExp = builder.build();

The and() method is only optional so theoretical it could be omitting.

This is equivalent to:

var regExp = new RegExp("^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$");

Or without using a string:

var regExp = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;

Name selecttion

Get the first last name with a beginning 'A'.

Text: Lewis,Amelia;Winston,Oliver;Adams,Emily;Ashton,Thomas

var regExp = new RegExp("A[a-zA-Z]*,[a-zA-Z]+");

Or with the builder:

var builder = new RegExpBuilder();
builder.matchesText("A").matchesFor("a-zA-Z").zeroOrMoreTimes().matchesText(",")
  matchesFor("a-zA-Z").oneOrMoreTimes();
var regExp = builder.build();

Tests

The tests are written for qUnit.

License

Refer for the license the license file