Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@putout/operator-regexp

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/operator-regexp

🐊Putout operator adds ability to check if provided regexp can be converted to string without losing it's sense

latest
Source
npmnpm
Version
5.1.0
Version published
Weekly downloads
13K
26.38%
Maintainers
1
Weekly downloads
 
Created
Source

@putout/operator-regexp NPM version

🐊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');

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;

transformRegExp(regexp: String, plugin: Traverser)

transformRegExp('[aab]', {
    report,
    fix,
    traverse,
});

getStringFromRegExp(pattern: String)

To avoid errors like this:

SyntaxError: Expecting Unicode escape sequence \uXXXX

const string = getStringFromRegExp(regexpNode);

License

MIT

Keywords

putout

FAQs

Package last updated on 01 May 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts