Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!noris.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <1458401.hGLh0OfnHy@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sun, 01 Sep 2013 15:25:24 +0200 User-Agent: KNode/4.10.5 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <3573991.qt74eh6WeI@PointedEars.de> MIME-Version: 1.0 Lines: 49 NNTP-Posting-Date: 01 Sep 2013 15:25:26 CEST NNTP-Posting-Host: b7f5d4c0.newsspool3.arcor-online.net X-Trace: DXC= You might instead find my jsx.regexp.RegExp useful, which among other > features allows you to name subpatterns and access by that name the > corresponding matches: > > /* ? style; also supports ?'Perl' style and ?P style */ > var regex = new jsx.regexp.RegExp("^(?.+?): (?.+)$", > "mg"), > str = "key1: val1\nkey2: key2", > match; > > while ((match = regex.exec(str))) > { > console.log(match.groups["first"], match.groups["second"]); > console.log(match[1], match[2]); > } > > “regex” holds an augmented RegExp instance then, whose inherited exec() > method has been overridden in the instance to return an augmented > array-like object if necessary (otherwise just the inherited method is > called, and its return value returned): > > /** > * @function > */ > exec: (function () { > var rx2; > > /** > * @param {string} s > * @param {jsx.regexp.RegExp} rx > * Instance to be tested > * @return {boolean} ^^^^^^^^^ > * true if rx has been constructed > * using this constructor, false otherwise. JFTR: As you can see further below, this is a documentation bug that will be fixed in the next revision. The return value of the custom method is exactly what the original RegExp.prototype.exec() method would have had returned (“null” or a reference to an Array-like object), augmented with custom properties if there is a match. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.