开发者

From Jquery how to determine split delimiter?

开发者 https://www.devze.com 2023-03-30 04:13 出处:网络
Let\'sif I have many split delimiters that I am going to use. How can I write a script in Jquery to determine the which delimiter to use for such case?

Let's if I have many split delimiters that I am going to use. How can I write a script in Jquery to determine the which delimiter to use for such case?

eg:开发者_如何学编程 ee 11

ee|11

ee|11

ee-11

If we take the above example, It should be spitted by checking the useage of delimiters - from the above list since '|' is twice, split should be done with '|' delimiter.

Any help would be appreciated thanks


You could just split on either...

var chunks = str.split(/[ |-]/);

jsFiddle.

0

精彩评论

暂无评论...
验证码 换一张
取 消