how to extract the first number from each string in a vector in R?

后端 未结 7 1163
醉话见心
醉话见心 2020-12-18 10:53

I am new to regex in R. Here I have a vector where I am interested in extracting the first occurance of a number in each string of the vector .

I have a vector calle

7条回答
  •  无人及你
    2020-12-18 11:22

    stringi would be faster

    library(stringi)
    stri_extract_first(shootsummary, regex="\\d+")
    #[1] "34" "42" "23" "27" "64"
    

提交回复
热议问题