Jump to content

Archived

This topic is now archived and is closed to further replies.

Brandon Jaeger

Some regex help, please

Recommended Posts

Hi, I need to replace anything between <div> tags with nothing ( "" ). What's the regex pattern for this?

Thanks in advance.

Share this post


Link to post
Share on other sites
Use something like this:

$text = preg_replace('/<div>.*?<\/div>/si', '<div></div>', $text);

or this:

$text = preg_replace('/<div>.*?<\/div>/si', '', $text);


depending on what you mean by "nothing".

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.