Jump to content

[SOLVED] Matching quotes not part of HTML tags


Recommended Posts

I made a website for a friend which has a WYSIWYG editor (TinyMCE). TinyMCE doesn't turn the quotes into their entity types, anyways that's the problem. I need to the keep the quotes used for HTML the way they are but to turn the other quotes into their entity types like so:

 

Original:

This is a block of "Text"

<span class="foo">bar</span>

 

What I need:

This is a block of "Text"

<span class="foo">bar</span>

 

What regex pattern would I need?

try

<?php
$test = 'This is a block of "Text"
blah "sasa"
<span class="foo">bar</span>

ddddddd "xxxx"';

$patern = '/(^|>)[^<]+/s';
function my_qoute($a){
return str_replace('"', '"', $a[0]);
}
$test = preg_replace_callback($patern, 'my_qoute', $test);
echo $test;
?>

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.