Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Find line above given text in document

    Help wanted · · · – – – · · ·
    3
    9
    332
    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.
    • Krithagis C
      Krithagis C last edited by

      Hello. I have a file that is Is over 100,000 lines long.

      What I’m trying to do is fine every line that shows ‡NO NAMES‡ and mark or display the line above it.

      So for something like this, I want to keep the bold lines:
      ADDRESS
      111 Main St
      LEVEL 4
      Anytown, USA
      FORM OF PAYMENT

      1. CASH TYPE
        CASH ‡

      *ZFWAQJ-P
      ‡NO NAMES‡

      *LUOKAG-P
      ‡NO NAMES‡

      I’ve tried a Linefilter plugin but it doesn’t seem to be working. Thanks so much.

      PeterJones Alan Kilborn 2 Replies Last reply Reply Quote 0
      • PeterJones
        PeterJones @Krithagis C last edited by

        @Krithagis-C

        • Search > Mark
        • Find What: (?-s)^.*$(?=\R‡NO NAMES‡)
        • ☑ Bookmark Line
        • ☑ Purge for each search
        • Search Mode = ☑ Regular Expression
        • Mark All

        06be7114-4ba0-46cc-8e21-01a606dc5470-image.png

        ----

        Useful References

        • Notepad++ Online User Manual: Bookmarks vs. Marks describes how to use Marks and Bookmarks, and how to easily navigate between bookmarked lines
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find regular expressions (regex) documentation
        • Please Read Before Posting
        • Template for Search/Replace Questions
        Krithagis C 1 Reply Last reply Reply Quote 3
        • Alan Kilborn
          Alan Kilborn @Krithagis C last edited by Alan Kilborn

          @Krithagis-C

          To show your bolded lines in the Search results window, you can do:

          Invoke Find window with Ctrl+f
          Find: (?-is)^.+\R‡NO NAMES‡
          Search mode: Regular expression
          Action: Press Find All in Current Document button

          and you’ll get something like this:

          d2575599-48c7-4a4f-89a2-b6f78ff1b816-image.png

          That seems to fit the bill for “display the line above it”. If you want the red-on-yellow text content, you can copy out of the Search results window.

          When you say “I want to keep the bold lines”, is that what you really mean, you want to delete all other text, in your original document?

          Which is it, displaying as I show (in Search results), marking in place as Peter shows, deleting all other text, or…something else?

          Krithagis C 2 Replies Last reply Reply Quote 3
          • Krithagis C
            Krithagis C @Alan Kilborn last edited by

            @Alan-Kilborn Thank you so much! Ultimately I only need to keep the line above ‡NO NAMES‡. There’s no need for bold or red as long as I have a way to grab all of those lines for further review. The NO NAMES means there’s an issue with that line that I have to review in another way.

            Alan Kilborn 1 Reply Last reply Reply Quote 0
            • Krithagis C
              Krithagis C @PeterJones last edited by

              @PeterJones Thanks this works for me. I can just copy marked text into another file and remove the ‡NO NAMES‡ text easily.

              Thanks so much!

              Alan Kilborn 1 Reply Last reply Reply Quote 0
              • Alan Kilborn
                Alan Kilborn @Krithagis C last edited by PeterJones

                @Krithagis-C said in Find line above given text in document:

                Ultimately I only need to keep the line above ‡NO NAMES‡… as long as I have a way to grab all of those lines for further review

                Then you can do this from the Search results result I showed before:

                • Right-click on the filename line (the line with green text that ends with (XXX hits))
                • Choose Copy Selected Line(s)
                • Create a new tab and then Ctrl+v (paste) there

                Here’s a screenshot where I demo the above (note that for maximum clarity I made a partial selection on the new 2 (2 hits) line before right-clicking it):

                2c3fd0c8-3993-465d-94e3-775f485e2969-image.png

                There’s no need for bold or red

                This is only a visual effect anyway, not part of the data. All you’ll get with the “Copy Selected Line(s)” technique is the data you seek:

                *ZFWAQJ-P
                *LUOKAG-P
                
                1 Reply Last reply Reply Quote 3
                • Alan Kilborn
                  Alan Kilborn @Krithagis C last edited by

                  @Krithagis-C said in Find line above given text in document:

                  PeterJones Thanks this works for me. I can just copy marked text into another file and remove the ‡NO NAMES‡ text easily.

                  If you’re using Peter’s technique as he stated and showed it, there would be no ‡NO NAMES‡ text to remove. The Copy Marked Text button will only copy what is red-marked, and, as you can see from Peter’s screenshot, ‡NO NAMES‡ is not red-marked.

                  1 Reply Last reply Reply Quote 3
                  • Krithagis C
                    Krithagis C last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • Krithagis C
                      Krithagis C @Alan Kilborn last edited by

                      @Alan-Kilborn Thanks so much to you and @PeterJones

                      It’s working now! I had my bottom search result hidden somehow and I haven’t used this app in awhile. This is going to save me SO MUCH TIME!!

                      b9c856c3-02ce-4200-a800-3f54d00f12e5-image.png

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post
                      Copyright © 2014 NodeBB Forums | Contributors