Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for negative matching for the below IP based regular expression:

True-Client-Ip: (25[0-5]|2[0-4][0-9]|[0-9]|[01]?[0-9][0-9]?).(25[0-5]|[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?$)

I have tried with putting negation ?! but that is not working.

share|improve this question
What regex engine are you using? ! is the classic negation char, but regexes tend towards greediness. – NickW Feb 24 '14 at 9:45
The aren't simple solution for negative regexp. Extremely huge solution exists, but this is surely not what you want. (It were at least more thousands of chars). You should solve this out of the regexp mechanism (f.e. some !match or some like this). – peterh Feb 24 '14 at 10:20
Actually, it is a custom device which uses regex. I am testing with ! will update if it works fine – Kunal Sharma Feb 24 '14 at 11:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.