[R] Regular expression help

Gabor Grothendieck ggrothendieck at gmail.com
Tue Dec 8 00:21:21 CET 2009


If I understand correctly you wish to extract strings of digits more
than 5 characters long:

s <- c("UV7C11-F9-E1 MCS#9831019", "MCS Lot #9512516")
library(gsubfn)
strapply(s, "\\d{6,}", c)

Depending on what you want to get back you might wish to add the
simplify=TRUE argument to strapply, as well.  See
http://gsubfn.googlecode.com


On Mon, Dec 7, 2009 at 6:04 PM, Ramya <ramya.victory at gmail.com> wrote:
>
> Hi  there
>
> I have a string like this i want to extract 9831019 from this string i used
> a regular expresion \d+ by which i can only make it to see 7 and returns.
> This type of number(9831019)  appears in any part of the string and is
> definitely more than 5 digits all the time and i want to give that as a
> condition
>
> UV7C11-F9-E1 MCS#9831019
> MCS Lot #9512516"
>
>
> how do i go abt it
>
> Ramya
> --
> View this message in context: http://n4.nabble.com/Regular-expression-help-tp954834p954834.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list