remix
regular expression alternation for tokenizers
Mixing
var re = new Re([/foo/, /bar/]);
var re = new Re([/foo/, /bar/i]);
Named matches
var Re = require('remix').ReMix;
var re = new Re('foo', /foo/, /bar/);
re.on('foo', function (name, match) {
console.log(match);
});
var str = 'foobar';
console.log(re.exec(str));
console.log(re.exec(str));
var re = new Re('foo', {foo: /foo/, bar: /bar/});
re.on('foo.bar', function (name, match) {
console.log(match);
});
re.on('foo.foo', function (name, match) {
console.log(match);
});
re.on('foo.*', function (name, match) {
console.log(match);
});
var str = 'foobar';
console.log(re.exec(str));
console.log(re.exec(str));
var re = new Re('foo', [/foo/, /bar/]);
var re = new Re({foo: /foo/, bar: /bar/});
Re.register('matchFoo', /foo/);
var re = new Re('foo', 'matchFoo');
var re = new Re('bar', '`matchFoo*`|bar');
Re.register('matchFooOrBar', '`matchFoo`|bar');
var re = new Re('bax', '\\s*`matchFooOrBar+`\\s*');