Javascript examples for String:split
The split() method splits a string into an array of substrings, and returns the new array.
If "" is used as the separator, the string is split between each character.
The split() method does not change the original string.
string.split(separator,limit)
Parameter | Description |
---|---|
separator | Optional. character, or regular expression, for splitting the string. If omitted, the entire string will be returned |
limit | Optional. the number of splits, items after the split limit will not be included in the array |
An Array, containing the splitted values
Split a string into an array of substrings:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* w ww. j av a 2 s . c om*/ var str = "How are you doing today?"; var res = str.split("o"); document.getElementById("demo").innerHTML = res; } </script> </body> </html>