poe Posted April 9, 2008 Share Posted April 9, 2008 i am reading an html file i want to replace everything between these 2 tags but cant figure it out <!-- REAP --> .... <!-- /REAP --> <!-- REAP --> <!-- PURGE:/baseball/mlb/gameflash/2008/04/02/19662_recap.html --> <!-- KEEP --> | <a href="/baseball/mlb/gameflash/2008/04/02/19662_recap.html">Recap</a> <!-- /PURGE:/baseball/mlb/gameflash/2008/04/02/19662_recap.html --> <!-- /REAP --> i have tried $myHtml = eregi_replace("<\!--REAP-->(.*?)<\!--\/REAP-->", "", $myHtml); but it doesnt work. Warning: eregi_replace(): REG_BADRPT Link to comment https://forums.phpfreaks.com/topic/100358-solved-delete-everything-between/ Share on other sites More sharing options...
Orio Posted April 9, 2008 Share Posted April 9, 2008 REG_BADRPT is given sometimes when special chars are not escaped. You can simply use preg_replace instead, it's faster most of the times too. Also, you need wrap your "REAP"s with spaces (like in your html): <?php $myHtml = <<<DATA <!-- REAP --> <!-- PURGE:/baseball/mlb/gameflash/2008/04/02/19662_recap.html --> <!-- KEEP --> | <a href="/baseball/mlb/gameflash/2008/04/02/19662_recap.html">Recap</a> <!-- /PURGE:/baseball/mlb/gameflash/2008/04/02/19662_recap.html --> <!-- /REAP --> DATA; $myHtml = preg_replace("#<\!-- REAP -->(.*?)<\!-- \/REAP -->#is", "", $myHtml); ?> Orio. Link to comment https://forums.phpfreaks.com/topic/100358-solved-delete-everything-between/#findComment-513230 Share on other sites More sharing options...
poe Posted April 9, 2008 Author Share Posted April 9, 2008 awsome... thanks Link to comment https://forums.phpfreaks.com/topic/100358-solved-delete-everything-between/#findComment-513233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.