I have a requirement, while adding API I need to add negative regex to URIs in such a way that I need to allow any request which does not match with that URIs.
I don’t want to allow /service/ip so I should give !/service/ip so that any URIs which does not match this regex should be rejected.
It might be easier to just match the “positive” side of the requests instead. Will the requests being processed have some structure on their path?
Also, by solving this with regexes, if someone tries to acces
/service/pi they will get a “404 NOT FOUND” status code. Make sure that this is what you want (you might want to return “401 UNAUTHORIZED” to make it more precise or “400 BAD REQUEST” to make it more generic).
Thanks for the response, I was able to apply negative match to URI but I could not able to add multiple patterns with and operation. Is it possible to match multiple URI patterns with and condition. I searched for regex in internet. Nothing is working, please help me.
I found the solution, it’s given below