如何在R中使用str_split和regex?

luk*_*awk 2 regex r strsplit stringr

我有这个字符串:

235072,testing,some252f4,14084-things224072,and,other2524,14084-thingies223552,testing,some/2wr24,14084-things
Run Code Online (Sandbox Code Playgroud)

我想用6位数字分割字符串.即 - 我想要这个:

235072,testing,some2wg2f4,wf484-things
224072,and,other25wg4,14-thingies
223552,testing,some/2wr24,14084-things
Run Code Online (Sandbox Code Playgroud)

我如何使用正则表达式执行此操作?以下不起作用(使用stringr包):

> blahblah <- "235072,testing,some252f4,14084-things224072,and,other2524,14084-thingies223552,testing,some/2wr24,14084-things"
> test <- str_split(blahblah, "([0-9]{6}.*)")
> test
[[1]]
[1] "" ""
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

Jul*_*ora 5

这是一种方法,基础R使用正向前瞻和后视,并感谢@thelatemail进行更正:

strsplit(x, "(?<=.)(?=[0-9]{6})", perl = TRUE)[[1]]
# [1] "235072,testing,some252f4,14084-things"  
# [2] "224072,and,other2524,14084-thingies"    
# [3] "223552,testing,some/2wr24,14084-things"
Run Code Online (Sandbox Code Playgroud)