Can someone please help me with the regular expression or php code that I need to do the following. I have a huge list of keywords and want to remove lines that contain certain $words = array("tickets","ticketmaster"); keyword list example dave matthews band ticketmaster dave matthews band tickets daytona 500 tickets daytona race tickets dc motor dc united tickets heather lee heather wayne heat press heat pump heavy metal concert tickets heels heins field helga sven hello kitty new help u sell real estate help wanted help wanted jobs hemp clothes hemp clothing henredon furniture Keyword List After lines with $words have been removed dc motor heather lee heather wayne heat press heat pump heels heins field helga sven hello kitty new help u sell real estate help wanted help wanted jobs hemp clothes hemp clothing henredon furniture Thanks
How big is "huge" and how much memory does PHP have available to it ? If the list is small compared to the available memory, something like this will do. $str = file_get_contents('keywords.txt'); $str = preg_replace('#^.*\b' . implode('\b|\b', $words) . '\b.*$#sim', "\n", $str); $str = preg_replace('#\n{2,}#', "\n", $str); Code (markup):