So I was solving this problem called String incrementer the other day: codewars.com/kata/54a91a4883a7de5d7800009c
let res = '' let regex = /([A-Za-z]*)(\d*)/g; let found = regex.exec('foo099');
By running this, the
found variable will return
and you could access the capturing groups using index (so the first group will be found, and so on). By using named capturing group, the found.groups property will be populated using an object with key as the name and value as the matched group. This definitely makes the code more readable.
You can read more about named capturing group for ES2018 here: 2ality.com/2017/05/regexp-named-capture-gro..