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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
poe Posted April 9, 2008 Author Share Posted April 9, 2008 awsome... thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.