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-28 23:12:40 +08:00
parent a12472597c
commit dde5d1579f
2 changed files with 3 additions and 0 deletions

View File

@@ -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);
// -- -- -- -- -- -- -- -- -- -- -- -- --

View File

@@ -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;