开发者

Javascript REGEX : Tags

开发者 https://www.devze.com 2023-01-15 18:52 出处:网络
I want to convert words into tags. So for example I have an input, if I type in in this apple, windows, stackoverflow, google, microsoft

I want to convert words into tags.

So for example I have an input, if I type in in this

apple, windows, stackoverflow, google, microsoft

then I will get this:开发者_开发百科

apple windows stackoverflow google microsoft

Delimiters should be space, semicolon, or comma, just like in stackoverflow :)


You can use the split method to split a string into an array, like this:

var tags = str.split(/\s*[ ,;]\s*/);
0

精彩评论

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