<?php
$str = "word <a href=\"word\">word</word>word word";
$str = preg_replace("/word(?!([^<]+)?>)/i","repl",$str);
echo $str;
# repl <word word="word">repl</word>
?>
source: http://pureform.wordpress.com/2008/01/04/matching-a-word-characters-outside-of-html-tags/
Unfortunality my project needs a semantic libs avaliable only for Java...
// Thanks Celso