peach a19a732be8 commit message | %!s(int64=2) %!d(string=hai) anos | |
---|---|---|
.. | ||
lib | %!s(int64=2) %!d(string=hai) anos | |
index.js | %!s(int64=2) %!d(string=hai) anos | |
license | %!s(int64=2) %!d(string=hai) anos | |
package.json | %!s(int64=2) %!d(string=hai) anos | |
readme.md | %!s(int64=2) %!d(string=hai) anos |
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