regexp anything but

58 Views Asked by At

I have an txt file with 65K lines. and not all are correct aligned.

So I need to replace the lines not ending with ;Yes or ;No with an space

Tried

^{^;Yes|^;No}$
2

There are 2 best solutions below

3
revo On BEST ANSWER

Select Perl while enabling Regular Expressions. Put this in Find What:

(?m)^.*$(?<!;Yes|;No)

Put a space character in Replace with input field.

Breakdown:

  • (?m) Enable multline flag
  • ^.*$ Match a whole line
  • (?<! Start of a negative lookbehind
    • ;Yes Last 4 characters shouldn't be ;Yes
    • | Or
    • ;No ;No
  • ) End of negative lookbehind

Live demo

0
Tim Biegeleisen On

Try the following find and replace in regex mode:

Find:

^(?!.*(Yes|No);$).*$

Replace:

(space)

Demo

This answer assumes that UltraEdit supports lookarounds. If not, then it won't work, and we would need an alternative approach.