flowforfrank / webtips

https://webtips.dev
1 stars 0 forks source link

webtips/javascript/how-to-convert-a-regexpstringiterator-to-an-array-in-javascript #9

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

How to Convert a RegExpStringIterator to An Array in JavaScript - Weekly Webtips

If are using String.matchAll in JavaScript, you get back a RegExpStringIterator, which you can loop through to get back the results. You can do this simpler

https://www.webtips.dev/webtips/javascript/how-to-convert-a-regexpstringiterator-to-an-array-in-javascript

ionescho commented 2 years ago

I did this and got inconsistent results, might be some js bug. When running the code in developer tools I get: [RegExpStringIterator] however, running it in the console manually, I get: [Array(1), Array(1), Array(1)]