For example, I have a string:
var s = "ABCDEFGHIJKLMN";
I would like to get an array of substrings whose length is 1 to 5.
The result I expect is:
["ABCDE", "FGHIJ", "KLMN"]
I tried to get the result via regexp. Here is my code:
var s = "ABCDEFGHIJKLMN";
var result = s.match(/(.{1,5})+/)
But I can only get the last match of the group instead of all of them:
result[1];
"KLMN"