$ npm install @putout/operator-regexp
🐊Putout operator adds ability to determine that provided RegExp can be
converted to String without losing it's sense.
It is used for example in regexp/convert-replace-to-relace-all:
-'hello'.replace(/hello/g, 'world');
+'hello'.replaceAll('hello', 'world');
npm i putout @putout/operator-regexp
const {operator} = require('putout');
const {isSimpleRegExp} = operator;
isSimpleRegExp(/hello world/);
// returns
true;
isSimpleRegExp(/^hello/);
// returns
false;
transformRegExp('[aab]', {
report,
fix,
traverse,
});
To avoid errors like this:
SyntaxError: Expecting Unicode escape sequence \uXXXX
const string = getStringFromRegExp(regexpNode);
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE