开发者

From Jquery how to determine split delimiter?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜