1.1.9 • Published 8 years ago

regexmatcher v1.1.9

Weekly downloads
5
License
ISC
Repository
github
Last release
8 years ago

regexmatcher

Synopsis

regexmatcher is a module for regular expression practice, testing and development with Node.js in mind.

Installation

# access your terminal
npm install --save regexmatcher

Example 1

const regexmatcher = require('regexmatcher'),
    results = regexmatcher.getMatches(/https?/gi, 'http HTTP https HTTPS ptth PTTH sptth SPTTH');

console.dir(results);
/* { matches:
[ [ 'http',
    index: 0,
    input: 'http HTTP https HTTPS ptth PTTH sptth SPTTH' ],
[ 'HTTP',
    index: 5,
    input: 'http HTTP https HTTPS ptth PTTH sptth SPTTH' ],
[ 'https',
    index: 10,
    input: 'http HTTP https HTTPS ptth PTTH sptth SPTTH' ],
[ 'HTTPS',
    index: 16,
    input: 'http HTTP https HTTPS ptth PTTH sptth SPTTH' ] ],
summary: 'There are 4 matches' } */

Example 2

const regexmatcher = require('regexmatcher'),
    results = regexmatcher.getMatches(/\(?\d{3}\)?-?\d{3}-?\d{4}/, '555-555-5555');

(results.matches.length === 1) ? console.log(results.matches[0][0]) : console.log('Please enter a valid North American telephone number...'); /* 555-555-5555 */

console.dir(results); /* { matches: [ [ '555-555-5555', index: 0, input: '555-555-5555' ] ],
  summary: 'There is 1 match.' } */

Motivation

I wanted to quickly practice and test strings for regular expression pattern matches without the overhead of UI tools.

Example Code

# access the terminal and go to the regexmatcher directory
# you must npm install to get this code to run
npm install

Running the example

# access the regexmatcher directory in your terminal
npm start

Running the linting and unit tests

# access the regexmatcher directory in your terminal
npm test
1.1.9

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago