简体   繁体   中英

preg_match_all(): Compilation failed: nothing to repeat at offset 203 runescape

Can someone please tell me why this wont work?

I am getting error "preg_match_all(): Compilation failed: nothing to repeat at offset 203"

$html = file_get_contents('http://services.runescape.com/m=itemdb_rs/results.ws?query='.urlencode($term).'&price='.$pricerange.'&members='.$members);
$html = str_replace(array("\r","\n"), "", $html);
$regexp = '#<tr data-item-id="(.*?)"><td class="(.*?)"><img src="(.*?)" alt="(.*?)"><a href="(.*?)">(.*?)</a></td><td><img src="(.*?)" alt="(.*?)" title="(.*?)"></td><td class="(.*?)">(.*?)</td><td class="(.*?)">(.?*)</td></tr>#';
preg_match_all($regexp, $html, $matches);
print_r($matches);

Example url that would be used in the file_get_contents

http://services.runescape.com/m=itemdb_rs/results.ws?query=gold%20bar&price=all&members=no

Thank you :)

I suggest your error is right here :

<td class="(.*?)">(.?*)</td></tr>#

Replace by

<td class="(.*?)">(.*?)</td></tr>#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM