Re: [R] Find String Between Characters

2011-05-15 Thread jim holtman
I would assume that you have lines of text that do not include 'CIK=' and therefore the 'sub' fails and you get the original string. If you only want the lines with "CIK", then use 'grepl' to just extract those lines before processing. On Sat, May 14, 2011 at 10:14 PM, Sparks, John James wrote:

Re: [R] Find String Between Characters

2011-05-15 Thread William Dunlap
jim holtman > Cc: r-help@r-project.org > Subject: Re: [R] Find String Between Characters > > Hi Jim, > > Thanks for your note. > > Unfortunately, when I attempt your solution in my exact > setting, I get a > weird and slightly different answer. > > First, let

Re: [R] Find String Between Characters

2011-05-15 Thread Sparks, John James
Hi Jim, Thanks for your note. Unfortunately, when I attempt your solution in my exact setting, I get a weird and slightly different answer. First, let me be more clear. What I am attempting to do is pull the CIK number out of the information from the web page itself after it has loaded to R (th

Re: [R] Find String Between Characters

2011-05-14 Thread jim holtman
Is this what you want: > mmm<-"http://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=320193&owner=exclude&count=40"; > num <- sub("^.*CIK=([0-9]+).*", "\\1", mmm) > num [1] "320193" > On Sat, May 14, 2011 at 8:20 PM, Sparks, John James wrote: > Dear R Helpers, > > I am trying to

[R] Find String Between Characters

2011-05-14 Thread Sparks, John James
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/c