When I test the code:
let result = 'heymama'.matchAll(/m(a)/g);
I get the error "'heymama'.matchAll is not a function"
When I run the version:
let result = 'heymama'.match(/ma/g);
There's no error.
matchAll() The matchAll() method returns an iterator of all results matching a string against a regular expression, including capturing groups.
Using regular expressions in JavaScript. Regular expressions are used with the RegExp methods test() and exec() and with the String methods match() , replace() , search() , and split() . Executes a search for a match in a string. It returns an array of information or null on a mismatch.
#String.matchAll
is supported in Node.js
from version 12.0.0
Check out the compatibility on MDN.
matchAll
is available in Node.js starting from v12.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With