1. clean-regexp
Clean up regular expressions
clean-regexp
Package: clean-regexp
Created by: samverschueren
Last modified: Mon, 13 Jun 2022 06:07:53 GMT
Version: 1.0.0
License: MIT
Downloads: 9,723,617
Repository: https://github.com/samverschueren/clean-regexp

Install

npm install clean-regexp
yarn add clean-regexp

clean-regexp Build Status

Clean up regular expressions

Install

$ npm install clean-regexp

Usage

 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'

API

cleanRegexp(regexp, [flags])

regexp

Type: string

Text of the regular expression.

flags

Type: string

Default: ''

Flags of the regular expression.

License

MIT © Sam Verschueren

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin