Skip to content
Discussion options

You must be logged in to vote

Ah okay, thanks for that. TL;DR: Use RegexMatcher::new_line_matcher instead of RegexMatcher::new, and that will fix most of the problem.

The issue here is subtle, and I missed the fact that your regex was .*foo.* instead of just plain foo. You also didn't show the actual ripgrep command you used. (In the future, it's best to include as much details as you can so that others can reproduce your experiment.) It's possible you're using .*foo.* intentionally, but in case you're not, foo will also report lines containing foo anywhere. The only difference with .*foo.* is that .*foo.* will match the entire line instead of just foo.

Anyway, that leading .* is key because it actually inhibits a cla…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
3 replies
@lightjacket
Comment options

@BurntSushi
Comment options

@lightjacket
Comment options

Comment options

You must be logged in to vote
5 replies
@BurntSushi
Comment options

@BurntSushi
Comment options

@lightjacket
Comment options

@BurntSushi
Comment options

@BurntSushi
Comment options

Answer selected by lightjacket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants