Search code examples
notepad++

remove every line that contains certain number after bar "|"


I have form that looks this:

12345678|123|123|123|123|
12345678|12|123|123|123|
12345678|123|123|123|123|
12345678|12|123|123|123|

starts with necessary with 8 random numbers | followed by 2 numbers or sometimes 3.

How can I remove every line/full line that contains 8 numbers and followed by three numbers after.

to get the final result:

12345678|12|123|123|123|
12345678|12|123|123|123|

Solution

    • Ctrl+H
    • Find what: ^\d{8}\|\d\d\d\|.+$\R?
    • Replace with: LEAVE EMPTY
    • CHECK Wrap around
    • CHECK Regular expression
    • UNCHECK . matches newline
    • Replace all

    Explanation:

    ^           # beginning of line
    \d{8}       # 8 digits
    \|          # a pipe
    \d\d\d      # 3 digits
    \|          # a pipe
    .+          # 1 or more any character but newline
    $           # end of line
    \R?         # any kind of linebreak, optional
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here