Delete Every line with that Word

后端 未结 3 917
生来不讨喜
生来不讨喜 2021-01-29 10:15

I want to delete the whole line if the line contains a specific word for example \"cat\".

If \"cat\" is in this line, delete the whole

相关标签:
3条回答
  • 2021-01-29 11:05

    Not necessarily a regex needed here

    1. Go to the search menu Ctrl+F (Strg+F, bzw. Suchen - Suchen)

    2. On the "Mark" tab, enter the word in the "Find what" field (Im "Vorkommnisse markieren" tab, das Scuhwort in "Suchen nach" eingeben)

    3. Check "Bookmark line" (Haken bei Lesezeichen setzen)

    4. Press "Mark all" ("Alle suchen")

    5. Goto Search - Bookmark - Remove Bookmarked lines (Im Menü Suchen - Lesezeichen - Zeilen mit Lesezeichen löschen auswählen)

    ==> you are done

    0 讨论(0)
  • 2021-01-29 11:09

    It is a two step process in notepad++. First do a regex replace

    Find what: ^(.*?)(cat)(.*?)$
    Replace with: 
    

    Next do a extended replace with

    Find what: \r\n\r\n
    Replace with: \r\n
    

    Assuming your file was created on Windows. However this will also remove all lines that previously had no content.

    Edit: Probably better to do the bookmark thing the other guy suggested.

    0 讨论(0)
  • 2021-01-29 11:12

    You need something like:

    [a-z]*cat[a-z]*

    I don't know if you have spaces or other special caracters...

    0 讨论(0)
提交回复
热议问题