feature request: comparing dict with strings to dict with regex values
I'd like to compare a dictionary where some of the expected values are regex to be matched to matching string values.
eg. something along:
actual = { 'a': 'abcd', 'b': 'test' }
# expecting 'b' to be exactly 'test' and expecting 'a' to be a four letter lowercase word
expected = { 'a': re.compile('[a-z]{4}'), 'b': 'test' }
print DeepDiff(actual, expected, regexMatching=True) # prints {}
I figure it will be very easy to implement, a small extension of type_changes from string to regex.
Hi @Iftahh
This is going to be tricky especially with ignore_order=True since we create the hash of all objects and won't know what we will be comparing that object to in the future when doing diffing. It is easy to implement it when ignore_order=False though. Sorry it took me such a long time to respond. Are you interested in making a PR for it?
+1 amazing feature to have Let's use regex based comparison too
"root[0]['Workspace']": {'new_value': '/auto/san1-99-box/prod/facebook/ncs5500/ws',
'old_value': '\\S+'}}}
+1 using regex for values comparison would be great. I work with network configuration and want to verify specific parts of the configuration which is deeply nested. Regexes are a must, for reasons that i cannot make obvious in a few lines.