Help with regular expression

0

I have tried, without success, to create a regular expression that allows me to differentiate values of a vector in R that have the following format

"sb183107"
"sb183108"
"sb183124"
"3989-15"
"761-16"
"3554-15"

I've tried with [^\d-] , [^sb][^\d] , [^sb] and sb\d+ but does not distinguish between cases.

It is about differentiating between the elements that start with sb and those that start with numbers. Eg executing sum(grepl('[^\d-]', vector)) where vector <- c("sb183107", "sb183108", "sb183124", "3989-15", "761-16", "3554-15") you get > [1] 6 when you should get only the sum of the elements that do NOT start with numbers

Any suggestions, please?

    
asked by arlugones 21.11.2018 в 17:07
source

0 answers