Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 31, 2024 via pnpm

balanced-match 1.0.2

Match balanced character pairs, like "{" and "}"
Package summary
Share
0
issues
1
license
1
MIT
Package created
13 Oct 2013
Version published
6 Apr 2021
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
balanced-match@1.0.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of balanced-match 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does balanced-match do?

Balanced-match is a JavaScript library designed for matching balanced string pairs, such as "{" and "}" or "<b>" and "</b>". It also provides flexible support for regular expressions. Qualifying this further, the library doesn't just identify the occurrences of these pairs, but discerns their balanced relationships within a given string, taking into account the opening and closing sequence, nested pairs, and more.

How do you use balanced-match?

The use of the balanced-match library is straightforward and intuitive. Firstly, you need to install it via npm, by running npm install balanced-match in your terminal. Once it's installed, you can require it in your JavaScript file as follows:

var balanced = require('balanced-match');

Thereafter, you can utilize the library to match balanced string pairs. Here's an example on how you could extract the first matching pair of braces:

console.log(balanced('{', '}', 'pre{in{nested}}post'));
console.log(balanced('{', '}', 'pre{first}between{second}post'));
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre  {   in{nest}   }  post'));

The output of these console.log statements display the details of the matched pairs such as their start and end indices within the string, and the preamble and postscript text excluding the pair elements.

Where are the balanced-match docs?

The complete documentation for balanced-match is available on its GitHub repository, accessible via the URL git://github.com/juliangruber/balanced-match.git. It provides detailed information about the API's parameters, the installation process, use cases, and more. The documentation extends to describing the output format and offering valuable insights on what to expect when dealing with unbalanced (misleading) pairs.