How I can isolate value of string (00010111001101000001011100011001) on strings by number of characters(8) use jquery and javascript?
I want this: Result: [ "00010111", "00110100", "00010111", "00011001" ]
How I can isolate value of string (00010111001101000001011100011001) on strings by number of characters(8) use jquery and javascript?
I want this: Result: [ "00010111", "00110100", "00010111", "00011001" ]
You can use .match
(with regexp \d{8}/g
) function which returns all characters(8)
console.log("00010111001101000001011100011001".match(/\d{8}/g));
Use substring
:
var s = "00010111001101000001011100011001";
var v = new Array();
for ( i = 0 ; i < s.length ; i+=8 ) {
v[i/8] = s.substring(i,i+8);
}
console.log(v);
Output:
["00010111", "00110100", "00010111", "00011001"]