modified xregexp.d.ts

=======================================================
// Matchception: Finding matches within matches, while passing forward and
// returning specific backreferences
html = '<a href="http://xregexp.com/api/">XRegExp</a>' +
       '<a href="http://www.google.com/">Google</a>';
XRegExp.matchChain(html, [
  {regex: /<a href="([^"]+)">/i, backref: 1},
  {regex: XRegExp('(?i)^https?://(?<domain>[^/?#]+)'), backref: 'domain'}
]);
// -> ['xregexp.com', 'www.google.com']
This commit is contained in:
Bibby
2014-12-30 00:32:11 +08:00
parent dde5d1579f
commit 1cef384b4f
2 changed files with 3 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ var exp: RegExp;
var expArr: RegExp[];
var chain: RegExp[];
var groupChain: { regex: RegExp; backref: string }[];
var groupChain1: { regex: RegExp; backref: number }[];
var regex: RegExp;
var value: any;
var str: string;
@@ -93,6 +94,7 @@ bool = XRegExp.isInstalled(str);
bool = XRegExp.isRegExp(value);
strArr = XRegExp.matchChain(str, chain);
strArr = XRegExp.matchChain(str, groupChain);
strArr = XRegExp.matchChain(str, groupChain1);
// -- -- -- -- -- -- -- -- -- -- -- -- --

View File

@@ -42,6 +42,7 @@ declare module 'xregexp' {
function isRegExp(value: any): boolean;
function matchChain(str: string, chain: RegExp[]): string[];
function matchChain(str: string, chain: { regex: RegExp; backref: string }[]): string[];
function matchChain(str: string, chain: { regex: RegExp; backref: number }[]): string[];
function matchRecursive(str: string, left: string, right: string, flags?: string, options?: Object): string[];
function replace(str: string, search: string, replacement: string, scope?: string): string;