Home > Software engineering >  Regular expression for numbers between 200 and 500 except 499
Regular expression for numbers between 200 and 500 except 499

Time:11-29

I need a regular expression for numbers between 200 and 500 except 499, but I don't know how to make that exception. It is for it's a regular expression for fail2ban, can you help me?

CodePudding user response:

/[23][0-9]{2}|4[0-8][0-9]|49[0-8]|500/

If RegExp is what you want, this would be it. If you give us more context, maybe there are better ways for this check.

Another alternative is to explicitly exclude 499 as a match:

/(?!499)[2-4][0-9]{2}|500/
  • Related