Try applying this to your file content. Well, NOT! Using that you obtain the exact opposite of what you want: $Output = StringRegExpReplace($Input, "(?m)(^.*(?:DEF|JKL).*$)", "")EDIT: of course you're right guys I misread the double negation in OP. I was completely upset by the behavior of this forum yesterday in my browser (pages would load completely 1/100 of the times, could never edit, ... That put me in a f*cking rage).