As mentioned in the "making words bold" thread, works aren't always separated by spaces. Sometimes they end a sentence so are followed by a period or other punctuation. Sometimes you have strings like "and/or" where they're separated by the forward slash, etc. You really have to do some kind of regex expression to get this right when substituting whole words and not just "any substring". A thought in the exact right direction, just need to follow through with the rest of the thought. -TG = = = Original message = = = I think that's a bad example you read. It doesn't describe how to search on a "word" it describes how to search on a string, which is what you ended up doing. For things like this I use arrays. Assuming your "words" are separated by spaces, you can get an array of all the words by doing: $word_list = explode(' ', $text); Then you can cycle through each element of the array (there are a number of ways to do this), testing if it equals your word and replace it if it does. Then put it all back together with: $text = implode(' ', $word_list); On May 11, 2005, at 12:13 PM, 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_using_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. > > Does anybody know how to do this on just words? > > Thank you for any hint, > > Merlin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ___________________________________________________________ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php