I have a bunch of 4XX status codes and I want to match all except 400 and 411.
What I currently have so far:
/4\d{2}(?!400|411)/g
Which according to regexer:
The expression 4\d{2}(?!400|411)
First matches a 4
and then 2 digits. After the matching, it asserts not 400 and 411 directly to the right.
Instead, you can match 4
and first assert not 00 or 11 directly after it.
4(?!00|11)\d{2}
Or without partial word matches using word boundaries \b
:
\b4(?!00|11)\d{2}\b
See a regex demo