Skip to content

jbnicolai/match-recursive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#match-recursive Build Status

Recursive regular expression matching for nested constructs

Heavily inspired by Steven Leviathan's article.

Ever wanted to match all contents between braces in a string, only to run into trouble with unmatched braces? Here's the solution!

Each [balanced, so this ']' bracket is ignored] subgroup will be matched recursively, ((2 + 2)*2)^2 will also match the outer group '(2 + 2)*2'. A second invocation will match the inner group '2+2'.

npm install match-recursive

##Usage examples

var matchRecursive = require("match-recursive");

matchRecursive("test    ",      "(...)");     // returns:   []
matchRecursive("(t(e)s)()t",    "(...)");     // returns:   ["t(e)s", ""]
matchRecursive("t<e>>st",       "<...>");     // returns:   ["e"]
matchRecursive("t<<e>st",       "<...>");     // returns:   ["e"]
matchRecursive("t<<e>>st",      "<...>");     // returns:   ["<e>"]
matchRecursive("<|t<e<|s|>t|>", "<|...|>");   // returns: ["t<e<|s|>t"]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published