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. Quote Link to comment 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); Quote Link to comment 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> 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.