Re: [R] grep(): returning the matched value

2008-01-14 Thread Romain Francois
Macnamara, Aidan wrote: > Hi, > > I'm looking to use the grep function (or something else) to return the > matched pattern as opposed to the whole element. For example: > > x <- c("pjhj24jhjhd") > grep("[[:digit:]]{2}", x, value=T) returns "people", whereas I simply want > "24". > > Any

Re: [R] grep(): returning the matched value

2008-01-14 Thread Macnamara, Aidan
Apologies, that should be grep("[[:digit:]]{2}", x, value=T) returns "pjhj24jhjhd" obviously. From: [EMAIL PROTECTED] on behalf of Macnamara, Aidan Sent: Mon 1/14/2008 14:04 To: r-help@r-project.org Subject: [R] grep(): returning the

[R] grep(): returning the matched value

2008-01-14 Thread Macnamara, Aidan
Hi, I'm looking to use the grep function (or something else) to return the matched pattern as opposed to the whole element. For example: x <- c("pjhj24jhjhd") grep("[[:digit:]]{2}", x, value=T) returns "people", whereas I simply want "24". Any help would be appreciated, Thanks, Aidan