Jump to content

Convert </div><div> into \n, but only within [css][/css] tags.


adamminer

Recommended Posts

Basically, I am using a JavaScript texteditor that excessively uses divs, which are showing up in SyntaxHighlighter. My issue is that many people on my site post CSS within [css] tags, but with my knowledge, I either convert all </div><div> into \n, or none of them at all. So how would i convert </div><div> into \n, but only within [css][/css]?

When you say match "</div><div>", do you mean exactly that? What about white space?

 

preg_replace('/(\[css\].*?)<\/div>\s*<div>(.*?\[\/css\])/s', '$1<br />$2', $str);

 

If you don't want it to match white space between the div tags, just remove "\s*".

Archived

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

×
×
  • Create New...

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.