Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
execall
Advanced tools
Find multiple RegExp matches in a string
Weekly downloads
Package description
The execall npm package is used to execute a regular expression against a string and return an array of matches, each with the matched text and index. It is particularly useful when you need to find all occurrences of a pattern in a string, not just the first one.
Finding multiple matches
This feature allows you to find all matches of a regular expression in a string. The example code searches for all occurrences of one or more digits in the given text and logs the array of match objects.
const execall = require('execall');
const regex = /\d+/g;
const matches = execall(regex, 'There are 3 apples and 5 oranges.');
console.log(matches);
The match-all package is similar to execall in that it also finds all matches of a regular expression in a string. However, it returns an iterator of matches instead of an array. This can be more efficient for large strings or when you only need to process matches one by one.
This package is a polyfill for the String.prototype.matchAll method, which is now part of the standard JavaScript library. It provides functionality similar to execall by returning an iterator of all results matching a string against a regular expression. The main difference is that matchAll is a method on the String prototype, while execall is a standalone function.
Readme
Find multiple RegExp matches in a string
Instead of having to iterate over RegExp#exec
, immutable, and with a nicer result format.
$ npm install execall
import execAll from 'execall';
execAll(/(\d+)/g, '$200 and $400');
/*
[
{
match: '200',
subMatches: ['200'],
index: 1
},
{
match: '400',
subMatches: ['400'],
index: 10
}
]
*/
Returns an object[]
with a match, sub-matches, and index.
Type: RegExp
Regular expression to match against the string
.
Type: string
FAQs
Find multiple RegExp matches in a string
The npm package execall receives a total of 1,329,000 weekly downloads. As such, execall popularity was classified as popular.
We found that execall demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.