This article describes the method of using the split function to split strings according to multiple characters. Share it for your reference. The specific analysis is as follows:
The split() function in js can split the string according to the specified symbol, but if there are multiple split symbols in the string, is the split() function of js still competent? The answer is yes. The split() function of js can realize the string segmentation of multiple separators through regular expressions, and the call is also very simple. The following is a detailed example.
The following code can be used to split strings by commas through js split method
var mystring = "a,b,c,d,e"; var myarray = (",");
If there is such a string: ",,baidu.com_weibo.com_haotu.net",
We want to split the website address by commas and underscores at the same time, refer to the following code:
var mystring = ",,baidu.com_weibo.com_haotu.net"; var myarray = (/[,_]/);
I hope this article will be helpful to everyone's JavaScript programming.