multiregexp

1.0.0 • Public • Published

multiregexp NPM version Build Status Code Climate Coverage

Use multiple RegExp like you had only one ! Iterate on matches or find the first match.

Quick example

import MultiRegExp from 'multiregexp'; // or var MultiRegExp = require('multiregexp');
const multiRegExp = new MultiRegExp([
    /hi/gi,
    /hello/gi,
]);
 
let firstMatch = multiRegExp.firstMatch('Hi ! Hello !');
console.log(firstMatch.toString());
// match= "Hi", start= 0, groupCount= 0
 
let firstMatch = multiRegExp.firstMatch('Oh hello ! Hi !');
console.log(firstMatch.toString());
// match= "hello", start= 3, groupCount= 0
 
for (let match of multiRegExp.allMatches('Oh hello ! Hi !')) {
    console.log(match.toString());
    // match= "hello", start= 3, groupCount= 0
    // match= "Hi", start= 11, groupCount= 0
}

Readme

Keywords

Package Sidebar

Install

npm i multiregexp

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • churpeau