-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Ending newline character of a line seems to be exposed to the regex engine with -P option #1401
Comments
Interesting, yeah, I think I might see why this happens. With the default regex engine, all character classes containing Thanks for filing this! |
Some extended testing.
Test data:
Just to make comparison complete:
In perl line contains \n at the end when you go over line by line. Seems pcre2grep does do that. Grep colors all matches correctly. Others do not do coloring. With rg:
Only "foo" is colored as match. Somehow first two lines end up being printed fully even if they are not marked as matches. |
This fixes a bug where PCRE2 look-around could change the result of a match if it observed a line terminator in the printer. And in particular, this is precisely how the searcher operates: the line is considered unto itself *without* the line terminator. Fixes #1401
What version of ripgrep are you using?
How did you install ripgrep?
Using
ripgrep_11.0.2_amd64.deb
What operating system are you using ripgrep on?
Ubuntu LTS 16.04
Describe your question, feature request, or bug.
When
-P
option is used,\s
seems to take ending newline character of input line into consideration.If this is a bug, what are the steps to reproduce the behavior?
Consider this sample input file:
Here's a minimal example showing the issue (I needed lookarounds, hence the need for
-P
switch)Another example shown below:
The text was updated successfully, but these errors were encountered: