String split with conditions in R

后端 未结 7 1353
一向
一向 2021-02-04 00:05

I have this mystring with the delimiter _. The condition here is if there are two or more delimiters, I want to split at the second delimiter and if th

7条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 00:50

    ^([^_\\n]*_[^_\\n]*)(?:_.*|\\.ReCal[^_]*)$
    

    You can simply do using gsub without using any complex regex.Just replace by \\1.See demo.

    https://regex101.com/r/wL4aB6/1

提交回复
热议问题