New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

remix

Package Overview
Dependencies
Maintainers
1
Versions
1082
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remix

regular expression alternation for tokenizers

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

remix

regular expression alternation for tokenizers

Mixing


/* unnammed prositional only matches */
var re = new Re([/foo/, /bar/]);

/* does not combine */
var re = new Re([/foo/, /bar/i]);

Named matches

  • example 1

var Re = require('remix').ReMix;

/* named match */
var re = new Re('foo', /foo/, /bar/);
re.on('foo', function (name, match) {
  /* 1st time ['foo', 3] */
  /* 2nd time ['bar', 6] */
  console.log(match);
});
var str = 'foobar';
/* [['foo', 3], [undefined]] */
console.log(re.exec(str));
/* [[undefined], ['bar', 6]] */
console.log(re.exec(str));

  • example 2

/* embedded matches are namespaced with parent name */
var re = new Re('foo', {foo: /foo/, bar: /bar/});
re.on('foo.bar', function (name, match) {
  /* ['bar', 6] */
  console.log(match);
});
re.on('foo.foo', function (name, match) {
  /* ['foo', 3] */
  console.log(match);
});
re.on('foo.*', function (name, match) {
  /* 1st time ['foo', 3] */
  /* 2nd time ['bar', 6] */
  console.log(match);
});

var str = 'foobar';
/* [['foo', 3], [undefined]] */
console.log(re.exec(str));
/* [[undefined], ['bar', 6]] */
console.log(re.exec(str));


/* alternative syntax */
var re = new Re('foo', [/foo/, /bar/]);

/* embedded named matches */
var re = new Re({foo: /foo/, bar: /bar/});

  • template examples

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*');

Keywords

FAQs

Package last updated on 26 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc