Jump to content

[SOLVED] Matching quotes not part of HTML tags


jordanwb

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

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.