jordanwb Posted February 23, 2009 Share Posted February 23, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/146444-solved-matching-quotes-not-part-of-html-tags/ Share on other sites More sharing options...
sasa Posted February 23, 2009 Share Posted February 23, 2009 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; ?> Quote Link to comment https://forums.phpfreaks.com/topic/146444-solved-matching-quotes-not-part-of-html-tags/#findComment-769066 Share on other sites More sharing options...
nrg_alpha Posted February 23, 2009 Share Posted February 23, 2009 Nice work, sasa You don't need the s modifier in this case however, as you are using a negated character class, not a dot match all. Quote Link to comment https://forums.phpfreaks.com/topic/146444-solved-matching-quotes-not-part-of-html-tags/#findComment-769111 Share on other sites More sharing options...
jordanwb Posted February 23, 2009 Author Share Posted February 23, 2009 Sweet, thanks Sasa. Quote Link to comment https://forums.phpfreaks.com/topic/146444-solved-matching-quotes-not-part-of-html-tags/#findComment-769135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.