JavaScript: Explode String Function
Question by Compi | 2017-12-15 at 18:17
From other programming languages, we all know the explode-function with which you can easily divide a string at a delimiter character or a separator string to multiple parts in order to get an array.
I have now tried several possibilities to use such a function also in JavaScript, but JavaScript seems not to know an explode. What can I do?
Related Topics
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
HTML5: Upload Images with Client Side Resize
Tutorial | 9 Comments
JavaScript: Show and hide HTML area by clicking a link
Tutorial | 0 Comments
jQuery: Send HTML5 Canvas to Server via Ajax
Tutorial | 0 Comments
jQuery: Scroll up and down with and without JavaScript
Tip | 0 Comments
JavaScript: Remove last character from string
Tip | 5 Comments
JavaScript: Catch Submit of Form
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
JavaScript indeed has an explode function. However, there, it is not called explode but .split().
Here is a small example how to use of this function.
Here, we want to separate the string "one two three" by a space. So, we have to pass a space to the split-function. After that, the variable arr is an array with the three elements "one", "two" and "three".
By the way, if you pass an empty string, for example s.split (""), you will get back an array that contains every single letter of the original string as an individual element.
Last update on 2020-10-01 | Created on 2017-12-16