开发者

javascript regex split

Is it possible to split a string twice with regex? For example, say I have the string:

开发者_Go百科example=email@address.com|fname|lname

how can I split to the result is:

email@address.com,fname,lname

thanks...


You can manually remove the prefix:

str.substr(str.indexOf('=') + 1)
   .split('|')


How about this?

var result=myString.split("=", 2)[1].split("|");


You want to search and replace the '|' to ' , '.

Why dont you use replace()

http://www.w3schools.com/jsref/jsref_replace.asp

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜