Comments (2)
You didn't provide a reproduction. Please provide one next time. I'll do it for you this time:
$ printf "foo\nquux\n" > haystack-with-trailing-newline
$ printf "foo\nquux" > haystack-no-trailing-newline
$ rg-13.0.0 -s -l '[^\n]\z'
haystack-no-trailing-newline
$ rg-14.0.3 -s -l '[^\n]\z'
haystack-with-trailing-newline
haystack-no-trailing-newline
The fact that that worked in ripgrep 13 was a bug. Anchors line \A
and \z
don't make sense with how you're using them because ripgrep is a line oriented searcher. There is no notion of "end of file." The only thing available to you is "end of line." And the logical model under which ripgrep operates is to search the contents of each line, and not the actual line terminators themselves.
The only way to have this work correctly is to enable multiline mode. In multiline mode, ripgrep is no longer line oriented, and treats the entire contents of each file as a single haystack. In that context, you can use anchors like \A
and \z
to mean "beginning of file" and "end of file," respectively.
In your case, you just need to add the -U
flag:
$ rg-13.0.0 -l -U '[^\n]\z'
haystack-no-trailing-newline
$ rg-14.0.3 -l -U '[^\n]\z'
haystack-no-trailing-newline
from ripgrep.
Thanks for the clarification.
from ripgrep.
Related Issues (20)
- Incorrect application of ignore rule with single glob in nested HOT 1
- Since nightly-2024-02-06 , could not compile with --features 'simd-accel' HOT 4
- rg allocates too much memory with: `rg --files --ignore-file ~/.ultimate-gitignore` HOT 2
- Repo HOT 1
- When i using rg to find file's type of rust, it doesn't work. HOT 1
- Typo in help description for --vimgrep option: "im" instead of "in" HOT 1
- rg spins in a nanosleep loop when one thread is blocked on a fifo
- [ignore] Fallback to use git check-ignore or support hook iteration HOT 3
- [feature request] Context up to a matching pattern instead of by fixed number of lines HOT 1
- ignore: WalkBuilder::build_parallel() example does not compile HOT 1
- FR: sort results by count HOT 1
- ripgrep does not properly apply ignore rules from .gitignore in parent directory
- global ignore / ripgreprc shell parameter expansion HOT 2
- unicode uppercase HOT 3
- Negation pattern/whitelisting is ignored from `--ignore-file` HOT 8
- .gitignore rule is matched incorrectly while in a subdir
- Adjacent replaced multiline matches result in wrong line numbers HOT 4
- Feature Request (globset): Expose `MatchStrategy` HOT 6
- Support decompression flags / smart use of zstd --long HOT 1
- Add `Select-String`/`sls` to the benchsuite HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ripgrep.