r grep by regex - finding a string that contains a sub string exactly one once

前端 未结 6 1874
暗喜
暗喜 2021-01-25 22:10

I am using R in Ubuntu, and trying to go over list of files, some of them i need and some of them i don\'t need,

I try to get the one\'s i need by finding a sub string

6条回答
  •  别那么骄傲
    2021-01-25 22:53

    we can try with ^ and $ to make sure that there is only a single 'a' in the string

    grep("^a$", a)
    #[1] 1
    

    It is not clear what the OP wanted.

提交回复
热议问题