JustinK101 Posted September 12, 2010 Share Posted September 12, 2010 I have a long string of html, and what I want to do, if find all occurrences of: /static (anything after)... and replace with: http://www.mydomain.com/static (anything after). What is the best and fastest way to do this? Thanks. Link to comment https://forums.phpfreaks.com/topic/213198-find-and-replace/ Share on other sites More sharing options...
AbraCadaver Posted September 12, 2010 Share Posted September 12, 2010 You'll want something more as you gave a trivial example, but: $string = preg_replace('#/static(.*)#', 'http://www.mydomain.com/static\\1', $string); Link to comment https://forums.phpfreaks.com/topic/213198-find-and-replace/#findComment-1110140 Share on other sites More sharing options...
JustinK101 Posted September 12, 2010 Author Share Posted September 12, 2010 Thanks for the reply. Ok, lastly, need to do something a bit more complicated. I want to search a large string of HTML for exactly: <div class="footer-parent"> and remove the entire HTML subtree under this. So basically delete all string HTML contained within: <div class="footer-parent"> // A whole bunch of nested html and markup, that should be deleted. </div> Link to comment https://forums.phpfreaks.com/topic/213198-find-and-replace/#findComment-1110142 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.