php - Do not replace anything when inside a html tag. Preg Regex -
i have regular expression:
$buffer = preg_replace("/'([a-za-z0-9]+)'/iu",'$1',$buffer);
it removes single quotes when there's no whitespace between quotes. replaces inside html tag. don't want so.
here's example
<div id="foo"></div>
should be:
<div id=foo></div>
and
<script>foo='bar'</script>
should not change , therefore be:
<script>foo='bar'</script>
html unpredictable, , cannot accurately handled regular expressions. unless created html , can very, of exact format, use html parser. if can, html parser far easier use, anyway.
sorry :/
Comments
Post a Comment