I finally had time to write another blog post last night. This one is about ripgrep, a fantastic search tool by @burntsushi5:
Fast Searching with ripgrep
https://mariusschulz.com/blog/fast-searching-with-ripgrep …
Super useful when searching for code and when writing codemods!
-
-
Replying to @mariusschulz
Awesome article! I think this is the light intro to ripgrep I've always wanted to write. :-) One small tip: instead of doing `rg \b(foo|bar|baz)\b`, you can actually do `rg -w 'foo|bar|baz'`. It will even be a little faster sometimes! (Hopefully!)
2 replies 0 retweets 5 likes -
Replying to @burntsushi5 @mariusschulz
Out of curiosity why would it be faster? Whats the optimisation that rg or its regex does in this case?
1 reply 0 retweets 0 likes -
Replying to @boyter @mariusschulz
It's a little subtle. Basically, `-w` doesn't actually do `\bfoo\b`. It does `(^|\W)(foo)($|\W)` and reports matches for the inner capture group. This is slightly different semantics than using `\b` that actually end up being more convenient. (GNU grep does the same.)
2 replies 0 retweets 2 likes
And the reason why that's faster is because \b *can* be slow when Unicode mode is enabled (which the default). In some cases, it will prevent the lazy DFA from running. But ripgrep tries to hard to avoid this. Literal optimizations usually drown out any slowness here.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.