Implemented MatchRegexpWithLineNumber() and MatchWithLineNumber()#224
Implemented MatchRegexpWithLineNumber() and MatchWithLineNumber()#224jessp01 wants to merge 2 commits intobitfield:masterfrom
MatchRegexpWithLineNumber() and MatchWithLineNumber()#224Conversation
These behave as `grep -n` does: output the matched line prefixed by the line number.
|
Hey @jessp01, thanks for the PR! This is a neat idea. Could you post a comment with some example code showing how this feature would solve a user's problem? I can't think of any situation in which I've needed to use the equivalent of |
|
Hi @bitfield , Yes, as it so happens, I am working on a Glow feature I need this for right now:) You can see a screencast where I demonstrate it. I'm using your module here Later, I will also use it to introduce search functionality in the built-in glow Pager (when it displays a given file). PS |
|
What I'm really looking for is an example of code that uses |
|
Well, as I wrote, I'd replace the call to And actually, as I write this, I think it would make sense to go a step further and revise these new methods so that they return the string and line number as separate values (in addition to outputting with |
|
Sure, try a few different ideas and see what looks best and makes most sense to you. Post the most compelling example here as a comment. If it's a problem lots of people have, and you come up with an elegant solution that justifies the cost of increasing the |
|
Hi @bitfield ,
I already have done:) This is a real feature I am working on that made this functionality necessary. Did you look at the code, pull description and screencast I've referenced? |
|
I think I'm missing something somewhere—the code you linked seems to use |
|
I'll close this for now, since it seems to have stalled—if you'd like to pick it up again at any point in the future, please do. |
These behave as
grep -ndoes: output the matched line prefixed by the line number.Simple test:
code:
Output: