Skip to content
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

Suggest -U when regex contains \n #1055

Closed
dtolnay opened this issue Sep 15, 2018 · 1 comment · Fixed by #1065
Closed

Suggest -U when regex contains \n #1055

dtolnay opened this issue Sep 15, 2018 · 1 comment · Fixed by #1065
Labels
enhancement An enhancement to the functionality of the software.

Comments

@dtolnay
Copy link
Contributor

dtolnay commented Sep 15, 2018

What version of ripgrep are you using?

ripgrep 0.10.0
-SIMD -AVX (compiled)
+SIMD +AVX (runtime)

How did you install ripgrep?

cargo install

Describe your question, feature request, or bug.

I tried this regex today: rg '=> \{\n *break;'. The output is:

the literal '"\n"' is not allowed in a regex

I would expect this error to suggest passing -U to enable multiline mode, in which that pattern would be allowed.

@BurntSushi
Copy link
Owner

This seems like a good idea! We already do the same with the -P flag if look-around or backreferences are used.

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Sep 15, 2018
BurntSushi added a commit that referenced this issue Sep 25, 2018
When a "\n literal is not allowed" error is reported, ripgrep will now
suggest the use of the -U/--multiline flag, which enables matching
newlines.

Fixes #1055
BurntSushi added a commit that referenced this issue Sep 25, 2018
When a "\n literal is not allowed" error is reported, ripgrep will now
suggest the use of the -U/--multiline flag, which enables matching
newlines.

Fixes #1055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants