1//split into array of strings.
2var str = "Well, how, are , we , doing, today";
3var res = str.split(",");
1var myString = "An,array,in,a,string,separated,by,a,comma";
2var myArray = myString.split(",");
3/*
4*
5* myArray :
6* ['An', 'array', 'in', 'a', 'string', 'separated', 'by', 'a', 'comma']
7*
8*/
1// Split string into an array of strings
2const path = "/usr/home/chucknorris"
3let result = path.split("/")
4console.log(result)
5// result
6// ["", "usr", "home", "chucknorris"]
7let username = result[3]
8console.log(username)
9// username
10// "chucknorris"
1// bad example https://stackoverflow.com/questions/6484670/how-do-i-split-a-string-into-an-array-of-characters/38901550#38901550
2
3var arr = foo.split('');
4console.log(arr); // ["s", "o", "m", "e", "s", "t", "r", "i", "n", "g"]
1var names = 'Harry ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ';
2
3console.log(names);
4
5var re = /\s*(?:;|$)\s*/;
6var nameList = names.split(re);
7
8console.log(nameList);