I use ripgrep for searching log files which works great. I like regexes a lot, so searching that supports them and is fast is always very helpful.
My question is - did you consider adding some more highlighting features so that I can highlight some parts of the text but not to include them in search pattern?
Example:
I search log files for batches with id 255
rg -F 255
7715:2016-10-01 05:22:00.683 DEBUG 41 PublishEvent CreateBatch{"BatchId":"b768eaf88faa4b....","Id":255 ...}
7824:2016-10-01 05:22:07.853 DEBUG 257 PublishEvent ProcessBatch{"UserId":98345,"Id":255 ...}
7888:2016-10-01 05:22:12.731 DEBUG 108 PublishEvent DeleteBatch{"Reason":"external","Id":255 ...}
It's ok to highlight the 255 value, but I'd like to get the event names (CreateBatch, ProcessBatch, ..) highlighted. This would help for quick eye scanning through the results.
I'm not particularly inclined to add another feature for this. It seems too complex to support more regexes that don't actually impact search results.
Is there any particular reason why you can't use pipes? For example, this works:
$ rg -F 255 issues-208 | rg '(Create|Process|Delete)Batch'
1:7715:2016-10-01 05:22:00.683 DEBUG 41 PublishEvent CreateBatch{"BatchId":"b768eaf88faa4b....","Id":255 ...}
2:7824:2016-10-01 05:22:07.853 DEBUG 257 PublishEvent ProcessBatch{"UserId":98345,"Id":255 ...}
3:7888:2016-10-01 05:22:12.731 DEBUG 108 PublishEvent DeleteBatch{"Reason":"external","Id":255 ...}
Honestly I didn't know about the pipeing functionality. I use ripgrep on windows where the command line tools have been quite useless. But this might help for sure in the future.
Back to the question - your proposed solution might work for some cases. But when I consider that the possible event types are hudreds, then it's not usable.
If I use regex "PublishEvent\s\w+", then both words will be highlighed.
I was considering also lookbehind (regex like "(?<=PublishEvent\s)\w+"), but according to https://doc.rust-lang.org/regex/regex/index.html#syntax it's not supported.
This is not critical feature, but might be interesting for some people. Anyway, I understand that implementing this feature is not very idiomatic.
Yeah, I'm going to close this. I can kind of understand why you'd want this, but it seems like too much trouble.
I will say that one possibly simpler approach would be to support an option to indicate a specific capture group to highlight instead of the full regex. So for example, you could do rg 'PublishEvent\s(\w+)' --highlight 1 and it would only color the text that matched (\w+).
I was just searching if there's a way to integrate with bat for the same reason.