开发者

javascript regex split

开发者 https://www.devze.com 2023-01-22 22:31 出处:网络
Is it possible to split a string twice with regex? For example, say I have the string: 开发者_Go百科example=email@address.com|fname|lname

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

精彩评论

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

关注公众号