R Regular Expression Lookbehind

后端 未结 3 923
夕颜
夕颜 2020-12-11 05:34

I have a vector filled with strings of the following format:

the first entries of the vector looks like

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-11 06:27

    Since this is fixed format, why not use substr? year1 is extracted using substr(s,1,4), id1 is extracted using substr(s,9,9) and the id2 as as.numeric(substr(s,10,13)). In the last case I used as.numeric to get rid of the zeroes.

提交回复
热议问题