How to exclude string from deepdiff comparison if matches regex expression

145 views Asked by At

Basically what I am trying to do is: if any value has the same root name, but different superscripts (ex: goodbyeᵃᵃᵃ vs goodbyeᵇᵇᵇ) then this should not be included as a difference.

Here is my code so far:

old_data = [{"test1": "hello", "test2": "goodbyeᵃᵃᵃ"}]
new_data = [{"test1": "hello", "test2": "goodbyeᵇᵇᵇ"}]

excludedRegex = re.compile(r'[a-zA-Z]+[\u02b0-\u207f]')


diff = DeepDiff(old_data, new_data, exclude_regex_paths= excludedRegex)
print(diff)

the output of this is

{'values_changed': {"root[0]['test2']": {'new_value': 'goodbyeᵇᵇᵇ', 'old_value': 'goodbyeᵃᵃᵃ'}}}

I'm new to deepdiff library so many I am not understanding it correctly?

0

There are 0 answers