-
Notifications
You must be signed in to change notification settings - Fork 444
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
In multi-line mode, ^$
unconditionally matches last line in text
#355
Comments
From the linked ripgrep issue comment:
|
This isn't a bug. The docs could be clearer, but they say:
In this case, the start of a line is the position immediately following This behavior also matches the semantics of Go, RE2 and Python. |
From Russ Cox's article, it seems this doesn't match PCRE's behavior:
I've truthfully never thought deeply about these particular semantics, but I think there would need to be a very compelling argument (probably insatiable) to change them at this point. |
And at least some of the tests here depend on the current semantics, although none of the tests precisely match your example: https://github.com/rust-lang/regex/blob/master/tests/multiline.rs |
I'm very surprised (again) by the semantics of the Python regex engine, which I thought I knew fairly well. I was definitely under the impression that it was designed to match PCRE. I did test that this doesn't match Perl's behavior. And for a grep tool like |
OK, I've posted a follow up on the ripgrep tracker: BurntSushi/ripgrep#416 I'll close this since I don't think this is a bug, it is consistent with at least several other popular engines, hasn't caused anyone any grief (that I know of) and would be a breaking change if we wanted to match PCRE exactly. |
I've discovered that
^$
, which should match empty lines, seems to unconditionally match the last line in text:This should not match, since there are no empty lines in
foo\n
; however, it prints:I believe this is a bug.
(First discussed here: BurntSushi/ripgrep#416.)
The text was updated successfully, but these errors were encountered: