How to use the matchRecursive function from xregexp
Find comprehensive JavaScript xregexp.matchRecursive code examples handpicked from public code repositorys.
146 147 148 149 150 151 152 153 154 155
Named subpatterns can be provided as strings or regex objects. A leading `^` and trailing unescaped `$` are stripped from subpatterns if both are present, which allows embedding independently-useful anchored patterns. `{{…}}` tokens can be quantified as a single unit. Any backreferences in the outer pattern or provided subpatterns are automatically renumbered to work correctly within the larger combined pattern. The syntax `({{name}})` works as shorthand for named capture via `(?<name>{{name}})`. Named subpatterns cannot be embedded within character classes. See also: *[Creating Grammatical Regexes Using XRegExp.build](http://blog.stevenlevithan.com/archives/grammatical-patterns-xregexp-build)*. ### XRegExp.matchRecursive In browsers, first include the script: ```html
90
165
25
85 86 87 88 89 90 91 92 93 94
result = XRegExp.match('... a+b*c ...', merge); console.log(result); // a+b*c // http://xregexp.com/api/#matchRecursive var str = '(t((e))s)t()(ing)'; result = XRegExp.matchRecursive(str, '\\(', '\\)', 'g'); console.log(result); // -> ['t((e))s', '', 'ing'] // Extended information mode with valueNames str = 'Here is <div> <div>an</div></div> example <div > and </div> more';
1
0
2
+ 7 other calls in file
1 2 3 4 5 6 7 8 9
var parse = function(str, opt_excludes) { var replaces = []; var comments = []; var recursive = XRegExp.matchRecursive(str, '\\/\\*', '\\*\\/', 'g', { valueNames: [null, null, 'value', null], escapeChar: '\\' });
0
1
2
+ 5 other calls in file
77 78 79 80 81 82 83 84 85 86
} private _getSizes(doc: vscode.TextDocument): Array<{range: vscode.Range, size: number}> { const docContent = doc.getText(); let returnValue: Array < {range: vscode.Range, size: number} >= []; const jsonStrings = XRegExp.matchRecursive(docContent, '\\{', '\\}', 'g', {valueNames: [null, 'left', 'match', 'right']}); if (jsonStrings.length % 3 !== 0) return returnValue; for (let index = 0; index < jsonStrings.length; index += 3) {
0
0
2
xregexp.exec is the most popular function in xregexp (52 examples)