好的,所以我目前正在解析RSS提要。我已经得到了我不需要的数据,而我剩下的所有数据都是解析游戏标题。preg_match(); - 未知的修饰符'+'
这里是我目前拥有的代码(忽略草率,它仅仅是一个概念验证):
<?php
$url = 'http://raptr.com/conexion/rss';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($result);
$lastgame = $xml->channel->item[0]->description;
preg_match('[a-zA-Z]+</a>.$', $lastgame, $match);
echo $match;
?>
一切是伟大的工作,但后来我开始收到此错误:
Warning: preg_match() [function.preg-match]:
Unknown modifier '+' in raptr.php on line 14
我剩下的唯一东西就是去掉结束标签和句号,但我似乎无法弄清楚为什么它不喜欢'+'。有任何想法吗?
编辑:这不应该被标记为重复,因为它是在两年前提出的另一个问题。
检查RSS源,你不想在那里使用'$'。 – mario 2011-04-08 02:48:19
当我删除$它只匹配“Conexion”,我欣赏虽然帮助! – 2011-04-08 02:54:13
你打算匹配什么?所有链接都有可能吗?然后尝试'preg_match_all'。否则,请尝试使用RSS解析器。 – mario 2011-04-08 02:57:11