I have this in my script that I'm writing:
$var = eregi_replace("(|[a-zA-Z])(($var))([a-zA-Z]|$)",' <B style="background-color:#CAD6E2">\2</B> ',$formatted);
What this does is "highlight" the word or words in $var in the string $formatted.
It works pretty well, except it when I have this combination of vars:
$var = "make"; ##try to highlight this word
$formatted = "[step]make your image this color[/step]"; ##in this string
When the script is done eregi_replacing() $formatted, my new string is:
$formatted = "[step <B style="background-color:#CAD6E2">make</B> your image this color";
The newly formatted string is missing "]" in the original "[step]" and it is needed for my script to run properly.
I'm not very good with regular expressions, but how could I fix my regular expression to only highlight full words (not parts of words) and keep the ] char?
Thanks for any help...
Andrew