Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
alexandrudima-oniguruma
Advanced tools
Native Node bindings to the Oniguruma regular expressions library.
Read all about Oniguruma regular expressions here.
Version 2.0 of this library added an asynchronous API, the old synchronous
methods have been renamed to have a Sync
suffix.
npm install oniguruma
npm install
grunt
to compile the CoffeeScript and native codenpm test
to run the specs{OnigRegExp, OnigScanner} = require 'oniguruma'
Create a new scanner with the given patterns.
patterns
- An array of string patterns.
Find the next match from a given position.
string
- The string to search.
startPosition
- The optional position to start at, defaults to 0
.
callback
- The (error, match)
function to call when done, match
will
null when there is no match.
scanner = new OnigScanner(['c', 'a(b)?'])
scanner.findNextMatch 'abc', (error, match) ->
console.log match
{
index: 1, # Index of the best pattern match
captureIndices: [
{index: 0, start: 0, end: 2, length: 2}, # Entire match
{index: 1, start: 1, end: 2, length: 1} # Match of first capture group
]
}
Synchronously find the next match from a given position.
string
- The string to search.
startPosition
- The optional position to start at, defaults to 0
.
Returns an object containing details about the match or null
if no match.
scanner = new OnigScanner(['c', 'a(b)?'])
match = scanner.findNextMatchSync('abc')
console.log match
{
index: 1, # Index of the best pattern match
captureIndices: [
{index: 0, start: 0, end: 2, length: 2}, # Entire match
{index: 1, start: 1, end: 2, length: 1} # Match of first capture group
]
}
Create a new regex with the given pattern.
pattern
- A string pattern.
Search the string for a match starting at the given position.
string
- The string to search.
startPosition
- The optional position to start the search at, defaults to 0
.
callback
- The (error, match)
function to call when done, match
will be
null if no matches were found. match
will be an array of objects for each
matched group on a successful search.
regex = new OnigRegExp('a([b-d])c')
regex.search '!abcdef', (error, match) ->
console.log match
[
{index: 0, start: 1, end: 4, match: 'abc', length: 3}, # Entire match
{index: 1, start: 2, end: 3, match: 'b', length: 1} # Match of first capture group
]
Synchronously search the string for a match starting at the given position.
string
- The string to search.
startPosition
- The optional position to start the search at, defaults to 0
.
Returns an array of objects for each matched group or null
if no match was
found.
regex = new OnigRegExp('a([b-d])c')
match = regex.searchSync('!abcdef')
console.log match
[
{index: 0, start: 1, end: 4, match: 'abc', length: 3}, # Entire match
{index: 1, start: 2, end: 3, match: 'b', length: 1} # Match of first capture group
]
Test if this regular expression matches the given string.
string
- The string to test against.
callback
- The (error, matches)
function to call when done, matches
will
be true
if at least one match is found, false
otherwise.
regex = new OnigRegExp('a([b-d])c')
regex.test 'abcdef', (error, matches) ->
console.log matches # true
Synchronously test if this regular expression matches the given string.
string
- The string to test against.
Returns true
if at least one match, false
otherwise.
regex = new OnigRegExp('a([b-d])c')
matches = regex.testSync('abcdef')
console.log matches # true
FAQs
oniguruma regular expression library
The npm package alexandrudima-oniguruma receives a total of 4 weekly downloads. As such, alexandrudima-oniguruma popularity was classified as not popular.
We found that alexandrudima-oniguruma 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.