New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
\K does not appear to work with --multiline #2528
Comments
If I add $ printf "foo\nbar" | rg --multiline --pcre2 --only-matching 'foo\nb\K(a)'
bar
$ printf "foo\nbar" | rg --multiline --pcre2 --only-matching 'foo\nb(a)'
foo
ba In some cases it could be worked around with negative look-behind but not always – in my full code I am getting: “lookbehind assertion is not fixed length” |
Looks like $ printf "foo\nbar" | rg --multiline --pcre2 'foo\nb\K(a)' --replace '$1'
bar Fortunately, here I can just drop $ printf "foo\nbar" | rg --multiline --pcre2 --only-matching 'foo\nb(a)' --replace '$1'
a |
So at a high level, for this specific case, the
Otherwise,
Unless you give ripgrep a flag to tell it to do otherwise, it always prints matching lines. But the output of
That really should just print The problem here is that ripgrep/crates/printer/src/util.rs Lines 387 to 442 in 4fcb1b2
At a more fundamental level, I fucked up the abstraction boundary between printing and searching, which makes this hard to fix properly. That abstraction boundary basically needs to go through a re-think. That means I'll classify this as a bug, but don't hold your breath for it getting fixed any time soon. The bug with
This is a PCRE2 limitation. Nothing I can do about that. |
You are right. The issue here is actually that the match is not highlighted. I started with Thanks for the informative response. Will use |
Ah yeah, the lack of highlights are indeed caused by the same underlying problem plaguing |
What version of ripgrep are you using?
How did you install ripgrep?
NixOS package.
What operating system are you using ripgrep on?
NixOS unstable
Describe your bug.
When I use PCRE 2 regex with
\K
in multiline mode, it will print the whole line instead only the part after\K
.What are the steps to reproduce the behaviour?
Run
What is the actual behaviour?
What is the expected behavior?
It should print just
ar
.The text was updated successfully, but these errors were encountered: