Numbers in a string
On Fri, Dec 17, 2010 at 07:39:46AM -0500, Gabor Grothendieck wrote:
On Thu, Dec 16, 2010 at 11:42 AM, Petr Savicky <savicky at cs.cas.cz> wrote:
[...]
Can something similar be done in R either specifically for numbers or for a general regular expression?
Dieter's first post in this thread already answered that question.
I am sorry for overlooking this solution using package gsubfn, although it was pointed out repeatedly in this thread. The following solves exactly the example i was asking for. library(gsubfn) s <- "abcde. 11 abc 5.31e+34, (1.45)" strapply(s, "[0-9]+\\.[0-9]+e[+-][0-9]+|[0-9]+\\.[0-9]+|[0-9]+")[[1]] [1] "11" "5.31e+34" "1.45" Thank you for this information. Petr Savicky.