I wanna match the word "hello" - case insensitive. But it has to be the word "hello" by itself, not "hellos" or "sfhello". And I want to use preg replace, so that the hello is the $1 variable. Poor explanation, I know, but I don't how else to explain. Should be relatively simple for those people who actually like regex.
You'd think so. My code: $var = "sfahellos"; $funcs="hello|test"; $result = preg_replace("~($funcs)~si","<span style='color:#00F;font-weight:bold'>$1</span>",$var); PHP: The problem is, the hello is still turning blue, which I don't want - unless $var equalled "hello" exactly. As $var equals "sfahellos", it shouldn't do anything. Cheers, BP
^hello|test$ works if your input is only one word. If you wanted to do it in a sentence you'd need to have spaces in your string.
I need to do it without spaces. And I've seen it done before, so I know its possible.... Thanks anyway.