regexp - find numbers in a string in any order

前端 未结 2 1417
温柔的废话
温柔的废话 2020-12-19 17:13

I need to find a regexp that allows me to find strings in which i have all the required numbers but only once.

For example:

a <- c(\"12\",\"13\",\         


        
2条回答
  •  暖寄归人
    2020-12-19 17:47

    you can as well use this

    grep('^([123])((?!\\1)\\d)(?!\\2|\\1)\\d', a, value=TRUE, perl=T)
    

    see demo

提交回复
热议问题