let str = "AAAAA-0000021111-1111";
let res = str.match(/\d(?=\d{4})/g);
document.write(res);
//This didnt work, the output is given below:
Output: 0,0,0,0,0,2
// its only selecting these characters which are highlighted in bold AAAAA-0000021111-1111
And this is what I am expecting:
A,A,A,A,A,-,0,0,0,0,0,2,1,1,1,1,-
Basically, I want all characters to be selected including - or any other special characters except the last 4.
I am listing a couple of extra samples for a better understanding
Sample1: ABC-101010-1111 Expected output is: A,B,C,-,1,0,1,0,1,0,-
Sample2: ABCD101010-11111 Expected output is: A,B,C,D,1,0,1,0,1,0,-,1
I am using Vanilla JS.
Really appreciate your involvement in this.
Thanks in Advance Sir/Ma'am!!!