1.0.0 • Published 9 years ago
multiregexp v1.0.0
multiregexp
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
}
1.0.0
9 years ago