1.4.3 • Published 6 years ago
@faden/matcher v1.4.3
Matcher
Better regular expressions
Matcher provides a very thin layer without any external dependencies around the inbuilt RegExp object, extending it by the ability to return all matches at once or by escaping a pattern before initializing the regular expression.
import { Matcher } from '@faden/matcher';
const helloMatcher = new Matcher('hello'); // Matcher { /hello/igm }
helloMatcher.matchAll('Hello..? HELLO!') // [ [ 0, 5, 'Hello' ], [ 9, 14, 'HELLO' ] ]Installing
With yarn
yarn add @faden/matcheror if you prefer npm
npm install --save @faden/matcherNotes
By default Matcher will create the regular expression with the flags i (case-independent), m (multiline) and g (global). Since g is set by default, the lastIndex of the underlying RegExp will be reset to 0 by default each time test is called. This can be changed by setting reset to false on the test method. Other methods clearly indicate what they do based on their names (e.g. matchFirst vs. matchNext)
API Documentation
Overview of the whole API
License
MIT
Credits
Christian Heine, Faden Limited