Community
    • Login

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

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 6 Posters 30.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • psteinP
      pstein
      last edited by

      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 Reply Last reply Reply Quote 0
      • jonandrJ
        jonandr
        last edited by

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

        .*aabbcc.*\r\n
        

        with nothing.

        1 Reply Last reply Reply Quote 0
        • ptonioloP
          ptoniolo
          last edited by

          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 Reply Last reply Reply Quote 0
          • David BaileyD
            David Bailey
            last edited by

            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 Reply Last reply Reply Quote 0
            • guy038G
              guy038
              last edited by 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 Reply Last reply Reply Quote 1
              • rishabh pantR
                rishabh pant
                last edited by

                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 Reply Last reply Reply Quote 1
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors