As info, SPFlite
does this easily (and at no cost).
The caveat is that this is a line-based
text editor (it's a clone of the IBM ISPF Edit facility, for any other old mainframers). As such it doesn't behave quite like what you're used to. But for certain things, SPFLite can satisfy like nothing else. I have a copy that I fire up when I need to do things that match its strengths.
As a line-based editor, you have line numbers on the left of the display and a command line at the top. Global types of commands (Find, for example) are entered at the top, and directives for one or more lines are entered in the line number area.
Per the original request, once a file is open, at the top you could type in "x all" (to exclude all lines, hide them from sight) and then "f mailbox all" which would locate every line that contains the word "mailbox" and make it visible:Text editor with filtering of lines
Any old ISPF Edit user can tell you that it can do things that are impossible in other editors. While that's probably not quite true, it makes a lot of things trivial that would take a lot of work in another editor. And there is definitely a withdrawal when you leave that environment... that's where SPFLite comes in. It is not a perfect clone, but it brings 95% of ISPF Edit and has been extended with additional features (and scripting in Basic, instead of Rexx, which I would prefer).
The free version has an innocuous nag screen that just tells you you're using the free version, and it only shows up more or less every 5th time you use the program, as you're exiting. If you donate (which I have) you get a small utility that fixes it not to display that screen.
As I said, this is not my main text editor, but it is extremely useful to have as a tool. I wish they had a "demo" script written, in the sense that you could follow the script with a sample file and see the unique things it can do.