Search for paragraphs without specific patterns #2077
-
Input
How is it possible to search for a paragraph consisting only of 1 line, without a specific pattern of charachters?
And if it is possible how would I do so for a paragraph consisting excatly of 5 lines?
I mix both cases here because I think the regex, if possible, will look very differently. Thanks in advance. Update: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
ripgrep is a line oriented tool. So it's generally not the right tool for this sort of task. By "line oriented tool," what I mean is that its basic mode of operation is to iterate over lines in a file and print only the ones that match. What you want to do requires something more powerful: the ability to reason about lines more holistically than that. ripgrep does not give you that arbitrary power. With that said, ripgrep does have a
EDIT: Obviously, this only works if you're using |
Beta Was this translation helpful? Give feedback.
-
At first thank you very much for your help. I tested it my windows pc but It didn't work. I tried it in CMD and Powershell. Did replace the ' with " for first debugging. In CMD:
Any idea what I am missing? |
Beta Was this translation helpful? Give feedback.
ripgrep is a line oriented tool. So it's generally not the right tool for this sort of task. By "line oriented tool," what I mean is that its basic mode of operation is to iterate over lines in a file and print only the ones that match. What you want to do requires something more powerful: the ability to reason about lines more holistically than that. ripgrep does not give you that arbitrary power.
With that said, ripgrep does have a
-U/--multiline
flag that will let you employ such reasoning in a limited way. To achieve what you want, for 1 and 5 lines, respectively: