String split with conditions in R

后端 未结 7 1349
一向
一向 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:45

    gsub('^(.*\\.\\d+).*','\\1',mystring)
    [1] "MODY_60.2"   "MODY_116.21" "MODY_116.3"  "MODY_116.4"
    

提交回复
热议问题