On Thu, Jun 7, 2012 at 1:40 PM, emorway wrote:
> Thanks for your suggestions. Bert, in your response you raised my awareness
> to "regular expressions". Are regular expressions the same across various
> languages? Consider the following line of text:
>
> txt_line<-" PERCENT DISCREPANCY =
Hello,
Just put the entire regexp between parenthesis.
extracted <-
strsplit(gsub("([+-]?(?:\\d+(?:\\.\\d*)|\\.\\d+)(?:[eE][+-]?\\d+)?)","\\1%&",txt_line),"%&")
extracted
sapply(strsplit(unlist(extracted), "="), "[", 2)
As for speed, I believe that this might take longer. It will have to
Hi Dan and Rui, Thank you for the suggestions, both were very helpful.
Rui's code was quite fast...there is one more thing I want to explore for my
own edification, but first I need some help fixing the code below, which is
a slight modification to Dan's suggestion. It'll no doubt be tough to be
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of emorway
> Sent: Thursday, June 07, 2012 10:41 AM
> To: r-help@r-project.org
> Subject: [R] extracting values from txt with regular expression
>
> Tha
Thanks for your suggestions. Bert, in your response you raised my awareness
to "regular expressions". Are regular expressions the same across various
languages? Consider the following line of text:
txt_line<-" PERCENT DISCREPANCY = 0.01 PERCENT DISCREPANCY =
-0.05"
It s
5 matches
Mail list logo