Extract a regular expression match in R version 2.10
- by tovare
Hi,
I'm trying to extract a number from a string.
And do something like this [0-9]+ on this string "aaaa12xxxx" and get "12".
I thought it would be something like:
> grep("[0-9]+","aaa12xxx", value=TRUE)
[1] "aaa12xxx"
And then I figured...
> sub("[0-9]+", "\\1", "aaa12xxxx")
[1] "aaa12xxx"
But I got some form of response doing:
…