-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
Problem
When ripgrep encounters an invalid regex (for example, an unclosed group), the error message is technically correct but may not be very helpful for users who are unfamiliar with regular expressions.
Example:
rg "(hello"
Output:
regex parse error:
(hello
^
error: unclosed group
While this correctly reports the error, it does not provide guidance on how to resolve it.
Proposed Improvement
Enhance regex error messages to provide more context and actionable guidance. For example, the message could include:
- The invalid pattern
- A clearer explanation of the error
- A helpful hint for common mistakes (e.g., unescaped metacharacters or missing delimiters)
Example (illustrative):
Invalid regex pattern: "(hello"
Reason: unclosed group
Hint: escape special characters like '(' or use -F for literal search
Why this helps
- Improves usability for users less familiar with regex
- Reduces confusion between regex and literal search behavior
- Provides actionable suggestions to resolve common mistakes
Willing to contribute
I’d be happy to work on implementing this improvement if it aligns with the project’s direction and maintainers’ preferences.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels