What Preg_replace code would I need to highlight all the code within the "<script </script>" tags in red.. (case insensitive)
What I want is a view_source.php page to highlight the javascript for a tutorial I'm writing. Can view the source ok but need to highlight the code.
Not a regular expression expert ;-(
UNTESTED:
<?
$old = "before before
<script type='text/javascript'>
function foo()
{
// bah
}
</script>
after after";// i assume the source will have htmlentities applied... $old = htmlentities($old);
// ...therefore we need to match on < and > rather than < and >
$new = preg_replace('/<script(.*?)>(.*?)<\/script>/ s','<script\\1><span style="color:red;">\\2</span></script>',$old);
echo "<pre>{$new}</pre>";
?>season to taste :)
Justin French
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

