Linked Questions

Popular Questions

Remove entire word if the word contains specific string

Asked by At

I would like to do the following, preferably with PHP:

Remove an entire word if a part of the word contains a specific string. This should be case insensitive and work multiple times, e.g. on a large text.

Pseudo-code:

match = "www."
lots_of_random_text = "... hello and welcome to www.stackoverflow.com! blah blah"
result = magic_function(lots_of_random_text, "www.")

result should now equal to: "... hello and welcome to blah blah".

How would I do this the most efficient way?

Related Questions