Socket
Socket
Sign inDemoInstall

curegex

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    curegex

Commonly Used REGular EXpressions


Version published
Weekly downloads
5
increased by25%
Maintainers
1
Install size
8.73 kB
Created
Weekly downloads
 

Changelog

Source

v0.0.4

  • upgrade modules
  • release with compact directory structure
  • add main and browser field in package.json.
  • further minimize generated js file with mangling and compression
  • remove assets files from git
  • patch test code to make it work with upgraded modules

Readme

Source

Commonly Used REGular EXpressions

Note

Some regular expressions here are vulnerable to ReDOS attack. Be sure to use them with following conditions:

  • server side: Run these expression with libraries such as google/re2, node-re2.
  • client side: avoid them, or at least impose necessary limitations on input.

Installation

npm install --save curegex

Usage

include curegex.js or curegex.tw.js, then use:

curegex.get("email").exec(mystring);
curegex.get("email", re2).exec(mystring); /* use `re2` regex engine instead of native RegExp */

set default regular expression engine:

curegex.engine(re2);

Usage with NodeJS

include curegex and use it by scope:

var curegex = require("curegex");
var curegextw = require("curegex").tw;

Resources

  • evil regex and rules of thumb: https://stackoverflow.com/questions/12841970/how-can-i-recognize-an-evil-regex
    • per James Davis mentioned, avoid following:
      • nesting quantifiers ( (a+)+ )
      • quantified overlapping disjunctions ( (a|a)+ )
      • quantified overlapping adjacencies ( \d+\d+ )
    • visualize regular expression to spot above cases: https://regexper.com/
  • https://en.wikipedia.org/wiki/ReDoS

License

MIT

FAQs

Last updated on 22 Jan 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc