Letting RegExp method return something iterable?

Erik Arvidsson erik.arvidsson at gmail.com
Mon Aug 26 11:33:58 PDT 2013


On Mon, Aug 26, 2013 at 1:05 PM, Andrea Giammarchi
<andrea.giammarchi at gmail.com> wrote:

> Long story short, I don't see any real use/case or any concrete advantage
> with those examples so please make it more clear what's the problem you are
> trying to solve and how these methods will concretely make our life easier
> ^_^

Having a way to get an iterable over all the matches is highly useful.
It is common to use such a construct in Python.

```py
for m in re.finditer(r"\w+", "aa b ccc"):
  print m.group(0)
```

```js
for (let m of 'aa b ccc'.matchAll(/(\w+/)) {
  print(m[0]);
}
```

-- 
erik


More information about the es-discuss mailing list