Find line above given text in document
-
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- 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.
- CASH TYPE
-
- Search > Mark
- Find What:
(?-s)^.*$(?=\R‡NO NAMES‡)
- ☑ Bookmark Line
- ☑ Purge for each search
- Search Mode = ☑ Regular Expression
- Mark All
----
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
-
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 buttonand you’ll get something like this:
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?
-
@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.
-
@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!
-
@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):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
- Right-click on the filename line (the line with green text that ends with
-
@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. -
This post is deleted! -
@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!!