Community
    • 登入

    How to mark all lines in a file containing pattern "aabbcc"?

    已排程 已置頂 已鎖定 已移動 General Discussion
    6 貼文 6 Posters 30.5k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • psteinP
      pstein
      最後由 編輯

      Assume I have a very large (huge) text file with 100000 lines, Think of a log file.

      I want to delete now all of the lines which contain a certain pattern simplified e.g. “aabbcc”.

      How can I achieve this?

      I miss a function/menu “display (only) all lines containing pattern”.
      Then I could mark+delete them.

      Can this option be added in the next release?

      Peter

      1 條回覆 最後回覆 回覆 引用 0
      • jonandrJ
        jonandr
        最後由 編輯

        Open find and replace dialog, check “Regular expressions”. Replace:

        .*aabbcc.*\r\n
        

        with nothing.

        1 條回覆 最後回覆 回覆 引用 0
        • ptonioloP
          ptoniolo
          最後由 編輯

          Mark the lines with the Find mask, then on the menu: Search/Bookmark/Remove Bookmarked Lines.

          @jonandr: be careful that the line ending could be a single linefeed: it’s better to put a question mark after the carriage return.

          1 條回覆 最後回覆 回覆 引用 0
          • David BaileyD
            David Bailey
            最後由 編輯

            I don’t know exactly what aabbcc is meant to stand for - does ‘a’ stand for one character?

            Anyway, you could do the search with a regular expression. Then you could create a macro out of a search followed by a line delete. After that, you could use the repeat macro button, and put in a large number.

            Remember that macros can be saved and then executed like other commands.

            David

            1 條回覆 最後回覆 回覆 引用 0
            • guy038G
              guy038
              最後由 guy038 編輯

              Hello Pstein,

              The remark of ptonolio about the End of Line characters is quite judicious ! But we can avoid the \r?\n syntax, using the syntax \R?. This syntax matches ANY optional end of line ( \r\n in Windows files, \n in Unix/OSX files and \r in Old Mac files )

              In addition, I would add the modifier (?-s), at the beginning of the search regex ( meaning NOT a SINGLE line ), just in case, you checked, by mistake, the . matches new line option, in the Replace dialog.

              To end, if you mind about the case, I would add the modifier (?-i) ( meaning NO IGNORE case ), just in case you forgot to check the Match case option

              So, according that you would like to delete any line, containing, exactly, the literal string aabbcc, choose the regular expression search mode, with :

              SEARCH : (?-is).*aabbcc.*\R?

              REPLACE : Nothing

              and click on the Replace All button

              Cheers,

              guy038

              1 條回覆 最後回覆 回覆 引用 1
              • rishabh pantR
                rishabh pant
                最後由 編輯

                Being in healthcare Services industry I have to work on manipulating Middleware data.
                One of the things that I found best about Notepad++ is multiple text editing options.

                To mark lines having same pattern:

                • Copy pattern and type Ctrl + f.

                • list item In Mark tab paste the pattern you are looking for in document.

                • list item Tick Bookmark Line button and click on Mark All.

                • list item Once all lines with pattern are marked you can delete them by

                • list item Go to Search --> Bookmarks --> Remove Bookmarked Lines.

                Refer this site for more descriptive and pictorial expalainations.

                http://www.downloadorinstall.com/best-notepad-tips-and-tricks-for-faster-work-and-development/

                1 條回覆 最後回覆 回覆 引用 1
                • 第一個貼文
                  最後的貼文
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors