Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/plotdb/curegex
commonly used regular expressions.
https://github.com/plotdb/curegex
Last synced: about 2 months ago
JSON representation
commonly used regular expressions.
- Host: GitHub
- URL: https://github.com/plotdb/curegex
- Owner: plotdb
- Created: 2020-12-13T16:17:47.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-22T07:58:32.000Z (almost 3 years ago)
- Last Synced: 2024-10-15T11:04:09.690Z (2 months ago)
- Language: Pug
- Size: 1.54 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# 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