@putout/operator-regexp
v1.0.0
Published
putout operator adds ability to check if provided regexp can be converted to string without loosing it's sense
Downloads
28,397
Maintainers
Readme
@putout/operator-regexp
putout
operator adds ability to determine is provided RegExp
can be
converted to String
without loosing it's sence.
It is used for example in regexp/convert-replace-to-relace-all:
-'hello'.replace(/hello/g, 'world');
+'hello'.replaceAll('hello', 'world');
Install
npm i putout @putout/operator-regexp
API
isSimpleRegexp(regexp: RegExp)
const {operator} = require('putout');
const {isSimpleRegExp} = operator;
isSimpleRegExp(/hello world/);
// returns
true;
isSimpleRegExp(/^hello/);
// returns
false;
License
MIT