Throwing StopIteration in array extras to stop the iteration
andrea.giammarchi at gmail.com
Mon Mar 4 08:38:19 PST 2013
I use RegExp.$1 , RegExp.$2, etc quite a lot since I am a huge fan of the
RAM and I believe creating a redundant array of matches for no reason since
these are retrievable in any case through the RegExp constructor,
considering exec and match points to those RegExp properties anyhow, ain't
needed when re.test(value) is involved.
If re.test(value) RegExp.$1;
As easy as that: 1) is *not* a bad practice and 2) is less redundant than
if (re.test(value)) match = re.exec(value);
I might agree about the ugly ness, the fact MDN is lacking those properties
I believe defined in the specs does not mean those properties are bad (as I
have just explained)
Also, that does not find a thing, that find an index ... and I forgot the
+RegExp['$&'] plus sign to have the integer.
We are programmers, we find solutions/alternatives/optimizations ... right?
On Mon, Mar 4, 2013 at 8:24 AM, Jeff Walden <jwalden+es at mit.edu> wrote:
> On 03/03/2013 06:53 PM, Andrea Giammarchi wrote:
> > I had to check msdn rather than MDN since latter does not mention it
> while mans shows an example:
> The RegExp statics aren't mentioned because they're a bad idea, imposing
> costs of some sort on pretty much all regular expression uses. Don't use
> And, um, this is quite possibly the most awful way to find a value in an
> array that I've ever seen. Even setting aside the statics usage!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss