Socket
Socket
Sign inDemoInstall

@stdlib/utils-escape-regexp-string

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stdlib/utils-escape-regexp-string

Escape a regular expression string or pattern.


Version published
Weekly downloads
474K
decreased by-3.67%
Maintainers
0
Weekly downloads
 
Created

What is @stdlib/utils-escape-regexp-string?

@stdlib/utils-escape-regexp-string is a utility package that provides functionality to escape special characters in a string so that it can be used within a regular expression. This is particularly useful when you need to dynamically create regular expressions from user input or other sources that may contain characters with special meanings in regex.

What are @stdlib/utils-escape-regexp-string's main functionalities?

Escape special characters in a string

This feature allows you to escape all special characters in a string so that the string can be safely used in a regular expression. In the example, the input string contains characters like '.', '?', and '()' which are escaped to '\.', '\?', and '\(\)' respectively.

const escapeRegExpString = require('@stdlib/utils-escape-regexp-string');
const str = 'Hello. How are you? (I hope you are well)';
const escapedStr = escapeRegExpString(str);
console.log(escapedStr); // Output: 'Hello\. How are you\? \(I hope you are well\)'

Other packages similar to @stdlib/utils-escape-regexp-string

Keywords

FAQs

Package last updated on 27 Jul 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc