I want to find values that match another value with a maximum of max_sub
substitutions.
I do the following:
item = 'ASDDGH'
Ref = 'ASDDGY'
max_sub = 1
rx = re.compile(item+ '{s<=' + str(max_sub) + "}")
rx.search(Ref)
Which returns the following like expected:
<regex.Match object; span=(0, 6), match='ASDDGY', fuzzy_counts=(1, 0, 0)>
However, if I do:
item = 'ASDDGH'
Ref = 'ASDAGY'
max_sub = 2
rx = re.compile(item+ '{s<=' + str(max_sub) + "}")
rx.search(Ref)
I get no matches, even though there are only 2 substitutions between the strings.
What am I doing wrong?
EDIT:
Thanks, got that working.
However, I am wondering why this shows up as a match:
item = 'WARQENW'
Ref = 'WARQRFWTAPLFDYW'
max_sub = 7
rx = re.compile("(" + item+ '){s<=' + str(max_sub) + "}")
rx.search(Ref)
The length of item and Ref are not the same, so more than just substitutions are happening, but the output suggests only 2 subs are made.