Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

balanced-match

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

balanced-match

Match balanced character pairs, like "{" and "}"

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
60M
increased by1.14%
Maintainers
1
Weekly downloads
 
Created

What is balanced-match?

The balanced-match npm package is used to match balanced string pairs, such as brackets, tags, or any arbitrary string pairs within a given input string. It helps in parsing and manipulating strings where nested structures are present.

What are balanced-match's main functionalities?

Match Balanced Pairs

This feature allows you to find the first pair of balanced strings within a given input. In this example, it finds the outermost curly braces and returns the body and the tails of the match.

var balanced = require('balanced-match');
var result = balanced('{', '}', 'pre{in{nested}}post');
console.log(result);

Match Range

Similar to the first feature, but instead of returning the matched strings, it returns the range (indexes) of the outermost pair. This is useful when you need to manipulate the string based on its position.

var balanced = require('balanced-match');
var result = balanced.range('{', '}', 'pre{in{nested}}post');
console.log(result);

Other packages similar to balanced-match

Keywords

FAQs

Package last updated on 07 Oct 2023

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