Remove pattern from string with gsub

前端 未结 4 1837
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 05:44

I am struggling to remove the substring before the underscore in my string. I want to use * (wildcard) as the bit before the underscore can vary:

a <- c(\         


        
4条回答
  •  爱一瞬间的悲伤
    2020-11-29 06:20

    Just to point out that there is an approach using functions from the tidyverse, which I find more readable than gsub:

    a %>% stringr::str_remove(pattern = ".*_")
    

提交回复
热议问题