Re: str_replace on words?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 11 May 2005 17:13, Merlin wrote:
> Hi there,
>
> I am trying to strip some words from a sentence. I tried it with
> str_replace like described here:
> http://www.totallyphp.co.uk/code/find_and_replace_words_in_a_text_string_us
>ing_str_replace.htm
>
> Unfortunatelly it does not work the way I want, because if I want to
> replace the word "in" all passages containing the characters "in" are
> replaced. For example Singapore.

You need to tokenize your input and do exact matching.  Alternately, 
preg_match / preg_replace may work with \b to specify word boundries.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux