Remove last occurrence of character

前端 未结 4 1360
醉梦人生
醉梦人生 2021-02-07 11:58

A question came across talkstats.com today in which the poster wanted to remove the last period of a string using regex (not strsplit). I made an attempt to do thi

4条回答
  •  甜味超标
    2021-02-07 12:19

    I'm sure you know this by now since you use stringi in your packages, but you can simply do

    N <- c("59.22.07", "58.01.32", "57.26.49")
    
    stringi::stri_replace_last_fixed(N, ".", "")
    # [1] "59.2207" "58.0132" "57.2649"
    

提交回复
热议问题