import re
r = re.compile('^/(?!(?:people|dungen)/[^?]+$).+/[^?]+$')
for s in ['/a/b/c/d', '/a/b', '/people/b/c/d', '/peoples/b/c/d', '/a/b/c?x=y']:
    pass
How can I make regex not accept some values?