I have the following file:
Fulltext = {"Apple Hospitality REIT, Inc. (APLE) Market Cap: $4.04B", "Arena Pharmaceuticals, Inc. (ARNA) Market Cap: $749.57M ", "Argo Group International Holdings, Ltd. (AGII) Market Cap:$1.81B ", "Armstrong Flooring, Inc. (AFI) Market Cap: $475.81M ", "Atlas Financial Holdings, Inc. (AFH) Market Cap: $183.47M ", "Avis Budget Group, Inc. (CAR) Market Cap: $2.6B "};
I just want to extract the following:
WhatIwant = {APLE, ARNA, AGII, AFI, AFH, CAR};
Although this example has only six extractions, I am looking for a more generic function that can be used to extract any number of strings that are within parentheses. Any help is greatly appreciated.
For clarity: I am importing a text file from a website using the following codes:
importeddata =
Import["http://www.nasdaq.com/earnings/earnings-calendar.aspx?date=\
2017-Aug-07", "Data"];
calanderdate = Flatten[importeddata[[2, 1]], 2];
calanderdate2 = calanderdate[[4 ;; Length[calanderdate] - 1]];
The calanderdate2 has a lot of companies' names and their ticker symbols in the middle within parentheses. I want to extract only the ticker symbols. Thanks
StringCases[str, "("~~s:Except["("|")"]..~~")":>s]– b3m2a1 Aug 06 '17 at 05:37Shortest, and if I remember correctly, the most efficient way usesRegularExpression. – JEM_Mosig Aug 06 '17 at 05:50Shortestisn't actually necessary because of both of theExceptcases and a rawShortestfails. I'm not surprisedRegularExpressionwins though. Post an answer with that and I'll upvote it. – b3m2a1 Aug 06 '17 at 05:51