http://FQDN/*.exe* // If found, print changed string and continue to next case. // If not found, check for form of // FQDN/*.exe* // If found, print changed string and continue to next case foreach ($lines as $line) { $newline = preg_replace( "=\s[Hh][Tt][Tt][Pp]://[^/]*/\S*\.exe\S*\s=", " [i]URL of executable deleted[/i] ", $line); if ($line != $newline) { echo "$newline\n"; continue; } else { $newline = preg_replace( "-(?(?=\s[Hh][Tt][Tt][Pp]://)\s[^Hh]|\s\S*/\S*\.exe\S*\s)-", "\1 [i]URL of executable deleted[/i] ", $line); if ($line != $newline) { echo "$newline\n"; continue; } else { echo "$line\n"; } } } ?>