Search accepts invalid regexes
Posted: 08 Dec 2021 18:16
Is it a bug? Is it a feature? After some deliberation I decided it's the former.
I tried to replace all occurrences of string at the end of the line with , so I used as my "find" string, checked "regular expressions" box, hit "replace all" and my editor hung. Then I did some experiments with various regexes and concluded that there's a serious bug in RJ TE's regex engine. Only when I checked my approach at RegExr excellent regex tester, I realized there's no bug in the editor, at least not the one I thought there was. Simply put, character I used (I = pipe) has special meaning in regular expressions... RegExr gives you this warning:
Where's the bug? The bug is accepting invalid regexes (in such cases RegExr warns you about an error, not gives a warning). Some examples:
source
If I use any of the above, RJ TE gives me "0 results", which is technically true, but misses the point, cf. this conversation on similar fault in NPP:
I tried to replace all occurrences of string
Code: Select all
|yes
Code: Select all
|1
Code: Select all
|yes$
I guess this was my case... It would be cool if RJ TE could give such warnings, too!The expression can return empty matches, and may match infinitely in some use cases.
Where's the bug? The bug is accepting invalid regexes (in such cases RegExr warns you about an error, not gives a warning). Some examples:
Code: Select all
*
[
[0-9]++
BOOM\
If I use any of the above, RJ TE gives me "0 results", which is technically true, but misses the point, cf. this conversation on similar fault in NPP:
I expect to be told that my regular expression is not correct, and other search activities to be aborted. Zero matches is misleading when the true problem is that a search parameter is incorrect.