Find String Between Characters
Is this what you want:
mmm<-"http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=0000320193&owner=exclude&count=40" num <- sub("^.*CIK=([0-9]+).*", "\\1", mmm) num
[1] "0000320193"
On Sat, May 14, 2011 at 8:20 PM, Sparks, John James <jspark4 at uic.edu> wrote:
Dear R Helpers, I am trying to isolate a set of characters between two other characters in a long string file. ?I tried some of the examples on the R help pages and elsewhere, but I am not able to get it. ?Your help would be much appreciated. require(scrapeR) mmm<-scrape(url="http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=0000320193&owner=exclude&count=40") str(mmm) I want to get the number 0000320193 that is between the CIK= and the &. ?I have tried g <- grep( "CIK=|&", mmm ) and temp<-grep(mmm,\CIK=\&) and variations on these themes, but all won't run or come bask as an empty object. ?How can I grab this number? Best wishes, --John J. Sparks, Ph.D.
______________________________________________ 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.
Jim Holtman Data Munger Guru What is the problem that you are trying to solve?