javascript split on multiple characters – Separate parts from a string with the split function. also you can RegExp / JavaScript: Split string on multiple characters.
Split into characters, strings, and patterns.
string.split(separator, limit)
Removing spaces from a string
var tutorials = "In the following example, split() looks for spaces";
var strings = tutorials.split(' ');
strings.forEach(displayProfile);
function displayProfile(item, index) {
document.getElementById("result").innerHTML += index + ":" + item + "<br>";
}
let string = "welcome awesome, Message!"
string.split(/[\s,]+/)
// welcome,awesome,Message!
index.html
<html>
<head>
<title>Split a string with multiple separators in javascript</title>
</head>
<body>
<div id="tutorials">Name and player of the; Union.—(1) Rajkot, that is Salman, shall be a India.</div>
<br /><br />
<div id="result"></div>
<script>
var tutorials = document.getElementById("tutorials").innerHTML;
var strings = tutorials.split(/[;,—]+/);
strings.forEach(displayProfile);
function displayProfile(item, index) {
document.getElementById("result").innerHTML += index + ":" + item + "<br>";
}
</script>
</body>
</html>
foo.match(new RegExp('.{1,' + n + '}', 'g'));
Don’t Miss : Jquery Split String To Array
how to split by words and punctuation in javascript?
string.split(/\s*\b\s*/)
I hope you get an idea about javascript split on multiple characters.