Re: [R] Pull Stock Symbol Out of String

2014-04-08 Thread arun
Hi, You may try: library(qdap) str1 <- c("American Tower Corporation (REIT) (AMT)", "Aetna Inc. (AET)") unlist(lapply(bracketXtract(str1,"round"),tail,1),use.names=F) #[1] "AMT" "AET" A.K. On Tuesday, April 8, 2014 7:48 PM, "Sparks, John James" wrote: Dear R Helpers, My regex skills are beg

Re: [R] Pull Stock Symbol Out of String

2014-04-08 Thread Boris Steipe
You could try: # Use ?regexec and ?regmatches to return a list of grouped matches. # Use \\( and \\) to match literal parentheses. # Use ... to match three characters. # Use $ to match at end of string. s1 <- "American Tower Corporation (REIT) (AMT)" s2 <- "Aetna Inc. (AET)" getSym <- function

Re: [R] Pull Stock Symbol Out of String

2014-04-08 Thread William Dunlap
> Of Sparks, John James > Sent: Tuesday, April 08, 2014 11:29 AM > To: r-help@r-project.org > Subject: [R] Pull Stock Symbol Out of String > > Dear R Helpers, > > My regex skills are beginner to intermediate and banging around the web > has not resulted in a solution to

[R] Pull Stock Symbol Out of String

2014-04-08 Thread Sparks, John James
Dear R Helpers, My regex skills are beginner to intermediate and banging around the web has not resulted in a solution to the problem below so I hope that one of you who has mad skills can help me out. I want to extract the stock ticker--AMT-- out of the string American Tower Corporation (REIT)Â