开发者

RegExp split a string by its middle character matches

I'd like to split all the instances of a character that aren't the starting or ending character. For example: "go good golly gog".split(RegExp) would go to ["go ","ood ","olly ","o开发者_开发技巧g"].

Is this RegExp possible?


Is this what you want?

"go good golly gog".split(/(?!^)g(?!$)/)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜