Узел JS Split
str.split([separator[, limit]])
Horrible Hyena
str.split([separator[, limit]])
function splitStr(str) {
// Function to split string
var string = str.split("*");
console.log(string);
}
// Initialize string
var str = "Welcome*to*GeeksforGeeks";
// Function call
splitStr(str);
function splitString(stringToSplit, separator) {
var arrayOfStrings = stringToSplit.split(separator);
console.log('The original string is: "' + stringToSplit + '"');
console.log('The separator is: "' + separator + '"');
console.log('The array has ' + arrayOfStrings.length + ' elements: ' + arrayOfStrings.join(' / '));
}
var tempestString = 'Oh brave new world that has such people in it.';
var monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
var space = ' ';
var comma = ',';
splitString(tempestString, space);
splitString(tempestString);
splitString(monthString, comma);