Why does ripgrep fail to parse \[[^[]*\*[^[]*\]
but tools like grep and ag don't?
#2985
-
Please tick this box to confirm you have reviewed the above.
What version of ripgrep are you using?ripgrep version: 14.1.1 on ArchLinux
How did you install ripgrep?pacman -S ripgrep What operating system are you using ripgrep on?ArchLinux updated today Describe your bug.try to search for array definitions in C code where a '*' is used inside the brackets. What are the steps to reproduce the behavior?command:
This regex works with standard Linux grep or ag commands. What is the actual behavior?see above What is the expected behavior?actually search and find the proper matches |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is working as expected. Here's how to do what you want with ripgrep:
It is a non-goal for ripgrep to be compatible with grep. ripgrep's regex engine tends to require escapes more than older regex dialects in an effort to improve error messages and reduce ambiguity. Moreover, ripgrep's regex engine supports nested character classes. For example:
Neither grep nor ag supports this. This is one of the many reasons ripgrep doesn't try to be a POSIX compatible grep. |
Beta Was this translation helpful? Give feedback.
This is working as expected. Here's how to do what you want with ripgrep:
It is a non-goal for ripgrep to be compatible with grep.
ripgrep's regex engine tends to require escapes more than older regex dialects in an effort to improve error messages and reduce ambiguity. Moreover, ripgrep's regex engine supports nested character classes. For example:
Neither grep nor ag supports this. This is one of the many reasons ripgrep doesn't try to be a POSIX compatible grep.