I created vim
search pattern to find bad status codes:
/ [45][0-9][0-9]
It can find 504
or 499
or 404
(space before and after each number)
But I don't want it to find 404
. How to change my search pattern to make it skip 404
?
I created vim
search pattern to find bad status codes:
/ [45][0-9][0-9]
It can find 504
or 499
or 404
(space before and after each number)
But I don't want it to find 404
. How to change my search pattern to make it skip 404
?
Using a negative look-ahead for that number:
/\(.*404\)\@![45]\d\{2\}
UPDATE: Thanks to Karoly Horvath to point out that this regex
could fail with some numbers in the same line. Much better:
/\(404\)\@![45]\d\{2\}
Another way with a negative look-behind after the match:
/[45]\d\{2\}\(404\)\@<!
5[0-9][0-9]|4[1-9][0-9]|40[0-35-9]
The old-school pattern is:
I hope you don't have other black-listed codes, because this will get ugly very quickly.