root 3bf41bf355 update | 1 gadu atpakaļ | |
---|---|---|
.. | ||
lib | 1 gadu atpakaļ | |
index.js | 1 gadu atpakaļ | |
license | 1 gadu atpakaļ | |
package.json | 1 gadu atpakaļ | |
readme.md | 1 gadu atpakaļ |
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