1

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" ]

0

2 Answers 2

1

You can use .match (with regexp \d{8}/g ) function which returns all characters(8)

console.log("00010111001101000001011100011001".match(/\d{8}/g));

Sign up to request clarification or add additional context in comments.

1 Comment

Important to point out is that the rest of the string will be discarded (ignored) if the length of the string is not a multiple of 8.
0

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"]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.