Javascript String Split by space and by word

Description

Javascript String Split by space and by word


let myString = "CSS, HTML, Javascript.";

let myArray = myString.split(" ");

for (let i = 0; i < myArray.length; i++)
  console.log(myArray[i]);//from w w  w  .  ja  va 2 s .  co  m
  
console.log(""); // create a space

myArray = myString.split(/[^a-z]+/gi);

for (let i = 0; i < myArray.length; i++)
  console.log(myArray[i]);



PreviousNext

Related