开发者

RegExp split a string by its middle character matches

开发者 https://www.devze.com 2023-03-14 16:08 出处:网络
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开发者_开

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

精彩评论

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