first example:
Code: Select all
<td>Company</td><td><span class="s4">+3.40%</span>Code: Select all
<td>Company</td><td><span class="s5">-201.30%</span>So far this is what I have for my regex:
Code: Select all
function mysql_past_5_earnings($ticker){
$url = "http://moneycentral.msn.com/investor/invsub/analyst/earnest.asp?Page=EarningsGrowthRates&Symbol=".$ticker;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$result = curl_exec($ch);
curl_close($ch);
$pattern = '!<td>Company</td><td><span\s*class="s4">([^<]*)</span>!';
preg_match($pattern,$result,$earnings);
$this->past_5_earnings = preg_replace('#(+[^.]*).(^%*)|([^.]*).([^%]*)#', '$1$2', $earnings[1]);
}The error returned from execution is:
Any help is appreciatedWarning: preg_replace(): Compilation failed: nothing to repeat at offset 1 in /home/clinton/hdd1/coldowl/project/stock/tests/graham.php on line 190