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 beat the time Rui's code finished the task in, but I'm willing to try. First, I need to fix the following, which 'peels' the wrong bit of text from "txt_line". Instead of extracting as it now does (shown below), can the code be modified to extract the values 0.01 and -0.05, and store them in the variable 'extracted'?
txt_line<-" PERCENT DISCREPANCY = 0.01 PERCENT DISCREPANCY = -0.05" extracted <- strsplit(gsub("[+-]?(?:\\d+(?:\\.\\d*)|\\.\\d+)(?:[eE][+-]?\\d+)?","\\1%&",txt_line),"%&") extracted #[1] " PERCENT DISCREPANCY = " " PERCENT DISCREPANCY = " -- View this message in context: http://r.789695.n4.nabble.com/extracting-values-from-txt-file-that-follow-user-supplied-quote-tp4632558p4632753.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.