BurntSushi / ripgrep

ripgrep recursively searches directories for a regex pattern while respecting your gitignore
The Unlicense
48.97k stars 2.01k forks source link

custom line terminator support. #2919

Closed Rose1917 closed 1 month ago

Rose1917 commented 1 month ago

Yes, I know ripgrep supports --crlf and --null-data options to change the default line seperator, and I also respect that "ripgrep is a line-based search tool".

But in my workflow I use ripgrep to filter log with the logging format:

[DEBUG][mod_a.cpp] some info
[TRACE][mod_a.cpp] other info that may
cover 
multiple
line
[DEBUG][mod_a.cpp] other info

in this case, by default, if I use ripgrep, the "cover", "multiple" "line" will be hide. Although I can use -C or A to handle this, but the extended info width is unsure.

If we can provide a custom terminator(for example, \n[ in this case, it will be nice.

BurntSushi commented 1 month ago

I think you should use multiline mode for this.

And even if I was willing, the custom line terminator would need to be a single byte. (To support multiple bytes, you would to add arbitrary length look around to the regex engine, and that ain't happening.)