我有一个这样的列表:
list <- c("xxx 23 cut", "yyy", "zzz", "www 55 cut", "kkk", "ggg", "yyy", "eee 7 cut", "ccd" )
Run Code Online (Sandbox Code Playgroud)
在这种情况下,搜索模式是"任意数字切割".因此,为了以更好的方式可视化列表,列表具有以下模式
"before item (=xxx) " "any number cut (= 23 cut)"
"after item (=yyy)"
"after item (=zzz)"
"before item (=www) " "any number cut (= 55 cut)"
"after item (=kkk)"
"after item (=ggg)"
"after items (=yyy)"
"before item (=eee) " "any number cut (= 7cut)"
"after item (=cce)"
Run Code Online (Sandbox Code Playgroud)
我想将"之前的项目"放在第1列,直到找到另一个"任意数字切割"模式,然后将"之后的项目"放到第2列.最终结果如下:
xxx yyy
xxx zzz
www kkk
www ggg
www yyy
eee ccd …Run Code Online (Sandbox Code Playgroud)