peach a19a732be8 commit message | 2 years ago | |
---|---|---|
.. | ||
lib | 2 years ago | |
index.js | 2 years ago | |
license | 2 years ago | |
package.json | 2 years ago | |
readme.md | 2 years ago |
Clean up regular expressions
$ npm install clean-regexp
const cleanRegexp = require('clean-regexp');
cleanRegexp('[0-9]');
//=> '\\d'
cleanRegexp('[^0-9]');
//=> '\\D'
cleanRegexp('[a-zA-Z0-9_]');
//=> '\\w'
cleanRegexp('[a-z0-9_]', 'i');
//=> '\\w'
cleanRegexp('[^a-zA-Z0-9_]');
//=> '\\W'
cleanRegexp('[^a-z0-9_]', 'i');
//=> '\\W'
cleanRegexp('[a-zA-Z\\d_]');
//=> '\\w'
cleanRegexp('[^a-zA-Z\\d_]');
//=> '\\W'
cleanRegexp('[0-9]+\\.[a-zA-Z0-9_]?');
//=> '\\d+\\.\\w'
Type: string
Text of the regular expression.
Type: string
Default: ''
Flags of the regular expression.
MIT © Sam Verschueren