From dde5d1579ffde5e8262f93cd1e2822b6f0840a42 Mon Sep 17 00:00:00 2001 From: Bibby Date: Sun, 28 Dec 2014 23:12:40 +0800 Subject: [PATCH] modified xregexp.d.ts ======================================================= // Matchception: Finding matches within matches, while passing forward and // returning specific backreferences html = 'XRegExp' + 'Google'; XRegExp.matchChain(html, [ {regex: //i, backref: 1}, {regex: XRegExp('(?i)^https?://(?[^/?#]+)'), backref: 'domain'} ]); // -> ['xregexp.com', 'www.google.com'] --- xregexp/xregexp-tests.ts | 2 ++ xregexp/xregexp.d.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/xregexp/xregexp-tests.ts b/xregexp/xregexp-tests.ts index 62d37439ef..1f093cafa7 100644 --- a/xregexp/xregexp-tests.ts +++ b/xregexp/xregexp-tests.ts @@ -9,6 +9,7 @@ import TokenOpts = X.TokenOpts; var exp: RegExp; var expArr: RegExp[]; var chain: RegExp[]; +var groupChain: { regex: RegExp; backref: string }[]; var regex: RegExp; var value: any; var str: string; @@ -91,6 +92,7 @@ XRegExp.install(obj); bool = XRegExp.isInstalled(str); bool = XRegExp.isRegExp(value); strArr = XRegExp.matchChain(str, chain); +strArr = XRegExp.matchChain(str, groupChain); // -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/xregexp/xregexp.d.ts b/xregexp/xregexp.d.ts index 9e30a2d077..886d242f04 100644 --- a/xregexp/xregexp.d.ts +++ b/xregexp/xregexp.d.ts @@ -41,6 +41,7 @@ declare module 'xregexp' { function isInstalled(feature: string): boolean; function isRegExp(value: any): boolean; function matchChain(str: string, chain: RegExp[]): string[]; + function matchChain(str: string, chain: { regex: RegExp; backref: string }[]): 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;