If you need to use regex you can use the following negative look ahead based regex :
^((?!"config").)*$
Demo
Along side the good notes by @Jerry and @nhahtdh You may note that this regex doesn't consider the type of words and i match the dictionaries that has config
in values.(you can see the detail in demo) as a better solution you can use json
module.
The following recursion function will do the task for any nested dictionary :
>>> def checker(s,val):
... for k in s:
... if k==val:
... return False
... elif isinstance(s[k],dict):
... return checker(s[k],val)
... return True
...
>>>
>>> s="""{"httpStatus": "OK", "payload": {"status": "OK"}, "httpCode": 200}"""
>>> js=json.loads(s)
>>> checker(js,'config')
True
>>> s="""{"httpStatus": "OK", "payload": {"status": "OK", "config": {}}, "httpCode": 200}"""
>>> js=json.loads(s)
>>> checker(js,'config')
False
And a nested dictionary :
>>> s="""{"httpStatus": "OK", "payload": {"status": "OK", "sts":{"nested":{"config": {}}}}, "httpCode": 200}"""
>>>
>>> js=json.loads(s)
>>> checker(js,'config')
False