Convert a string to an array

A string: for example,

var a = "";

[""""];

for
for (let j = 0; j < a.length; j += 5){
      let titlj = a;
      titlj += titlj[j].split(",")
      console.log(titlj[j].split(",")); //[""] [""]
    }
  :
  angualrlists:
  lists: Array<any> = [
        {
          title: [""],
          text: "xx"
        },
        {
          title: [""],
          text: "xx"
        },
        {
          title: [""],
          text: "xx"
        }
      ]
     :
         textRight() {
            console.log(this.lists)
            for (let i = 0; i < this.lists.length; iPP) {
              var str = this.lists[i].title.join();
              for (let j = 0; j < str.length / 4 ; jPP) {
                var text = str.slice(j * 4, (j + 1) *4);
                // console.log(text);
                var arrtext = text.split(",");
                // console.log(arrtext);
                this.lists[i].title = [];
                this.lists[i].title.concat(arrtext);
                
                this.lists[i].title = this.lists[i].title.concat(arrtext)
                console.log(this.lists[i].title);
        
              }
              console.log(this.lists[i].title);
            }
          }
       
     

clipboard.png


clipboard.png

Jul.17,2021

a.split(/(?<=^(?:\S{5})+)/)

is only available in newer browsers, and it is not compatible with polyfill and babel


 var a = "";

    function SplitStrToArr(str, num) {
      var arr = [];
      for (let j = 0; j < str.length / num; jPP) {
        var text = str.slice(j * num, (j + 1) * num);
        arr.push(text);
      }
      return arr;
    }
    console.log(SplitStrToArr(a, 5))

function splitWords(word, num) {
    let slices = [];
    const chars = word.split('');
    while (chars.length > 0) {
        slices = slices.concat(chars.splice(0, num).join(''));
    }
    return slices;
}

console.log(splitWords('', 5));

output

[ '', '' ]

let str = "";
let size = 5;
let length = Math.round(str.length / size);
const result = [];
for (let i = 0; i < length; iPP) {
  result.push(str.substr(i * size, size))
}
console.log(result)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32768-2b592.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32768-2b592.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?