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]?

Link to comment
Share on other sites

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*".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.