if (/my background error (\d+): (.+)/ ) { do something with the matched line } #### if (/my background error (\d+): (.+(?!my3\.exe))/ ) { do something with the matched line }