Re: [R] Extract number from string

2011-02-07 Thread Gabor Grothendieck
On Mon, Feb 7, 2011 at 9:37 AM, Roy Mathew wrote: > Dear R Users, > > if I have a string as follows > x<-"jsda23tth" > > How can I extract out 23 as a numeral? > I found > substr(x,5,6) > but, this doesnt work if the number of alphabets differ. > > This is another example where the numbers need to

[R] Extract number from string

2011-02-07 Thread Roy Mathew
Dear R Users, if I have a string as follows x<-"jsda23tth" How can I extract out 23 as a numeral? I found substr(x,5,6) but, this doesnt work if the number of alphabets differ. This is another example where the numbers need to be extracted. x<-c("jsda23tth","fgd54fgd","j3ngh","gfdjh564") any id