I have a string where i want to extract a particular pattern only.
x<-c("N4553","3805U","celeron N4553","applheddd")
gregextract <- gregexpr('\\bceleron\\b|\\bN[0-9]+\\b',x,perl=TRUE)
size1<- regmatches(x,gregextract,invert = FALSE)
It extracts both the occurrences of N
, I need only celeron
to be extracted(where a combination of celeron N4533
occurs) without N4533
. I cannot remove N[0-9]
pattern as it is used of other occurrences in different rows.