Let\'s say I have the string
\"12345\"
If I .match(/\\d{3}/g), I only get one match, \"123\". Why don\'t I get
.match(/\\d{3}/g)
\"123\"
I would consider not using a regex for this. If you want to split into groups of three you can just loop over the string starting at the offset:
let s = "12345" let m = Array.from(s.slice(2), (_, i) => s.slice(i, i+3)) console.log(m)