One more regex problem!

Hey again!

This time, my goal is to create a syntax highlighter using PHP. Here’s the deal: I have an array with every keyword used in Actionscript.

Here’s an example:

$KEYWORDS=array("goto","gotoAndPlay","trace");

-----replaces keyword with highlighted-----

for($i=0;$i<count($KEYWORDS);$i++) {
  $str = str_replace_callback("???","highlight",$str);
}

------this returns the colored code-----

function highlight($m) {
  $code = "<font color='#0099FF'.>".$m[1]."</font.>";
  return $code;
}

I figured that the best way to implement this was just to say "if the word in question doesn’t have any alphanumeric (AZaz09) directly to the right or left of it, then it counts.

How do you write that expression in Regex? That includes importing the array value ($KEYWORDS[$i]) dynamically into Regex.

Anyone who solves this one is my hero.