Splitting a file name into name,extension

前端 未结 3 1073
南笙
南笙 2020-11-29 04:32

I have the name of a file like this: name1.csv and I would like to extract two substrings of this string. One that stores the name1 in one variable

3条回答
  •  迷失自我
    2020-11-29 05:02

    Using regular expression, you can do this for example

    regmatches(x='name1.csv',gregexpr('[.]','name1.csv'),invert=TRUE)
    [[1]]
    [1] "name1" "csv"  
    

提交回复
热议问题