[R] Finding multiple characters in the same string

Vladimir Eremeev wl2776 at gmail.com
Thu Aug 2 13:17:09 CEST 2007


grep("[0-9]",unlist(strsplit("this1is2a3test","")),value=TRUE)


Tom.O wrote:
> 
> I have this problem where I need to find if there is any numbers in a
> string, this is no problem if theres only one number per string. I would
> then simply use the regexpr() funtion togheter with the substring function
> to extract the number. But regexpr only picks one number per string either
> from the beginning or the end, but not multiple. Can this be done? And how
> 
> for example
> My string <- "this1is2a3test"
> 
> The result I want is an vector of c(1,2,3)
> 

-- 
View this message in context: http://www.nabble.com/Finding-multiple-characters-in-the-same-string-tf4205206.html#a11962578
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list