extract dates from yahoo finance - please help!
古いコメントを表示
I am trying to "scrape" stock data from yahoo finance. Although I am successful in extracting the stock prices, I am having difficulties in extracting the dates. I am using the following command without success:
dateField=regexp(historicalPriceFile, '<td class="yfnc_tabledata1" nowrap align="right">([\d\w-]+)</td>', 'tokens');
Please help!
Thank you in advance,
Chris
7 件のコメント
Walter Roberson
2012 年 12 月 24 日
Could you give an example line to be matched?
Side note: \w includes digits, so [\d\w-] can be simplified to [\w-]
Chris
2012 年 12 月 24 日
編集済み: Walter Roberson
2012 年 12 月 24 日
Walter Roberson
2012 年 12 月 24 日
編集済み: Walter Roberson
2012 年 12 月 24 日
The date you shows has spaces and commas, which [\d\w-] does not include. The date does not appear to have any dash. Perhaps [\w\s,]
Chris
2012 年 12 月 24 日
Walter Roberson
2012 年 12 月 24 日
[\w\s,] works for me.
Your sample date has no '-' in it, so no point having the '-' in the []. Your sample date has a space and comma in it, which are not matched by [\w-]
Chris
2012 年 12 月 24 日
Chris
2012 年 12 月 25 日
回答 (1 件)
Walter Roberson
2012 年 12 月 25 日
dateField=regexp(historicalPriceFile, '<td class="yfnc_tabledata1" nowrap align="right">([\w\s,]+)</td>', 'tokens');
... as discussed above.
カテゴリ
ヘルプ センター および File Exchange で Financial Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!