amjith / fuzzyfinder

Fuzzy Finder implemented in Python
BSD 3-Clause "New" or "Revised" License
370 stars 30 forks source link

Use shortest match if matches overlap #8

Closed sudormrfbin closed 6 years ago

sudormrfbin commented 6 years ago

The regex used for finding matches, matches the longest one if they overlap.

import re

regex = re.compile('.*?'.join('fuz'))

regex.search('vfuzzzz')   # 'fuzzzz' is matched instead of 'fuz'

So I used look ahead assertions to get the shortest match.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 184173860e372da87b5bb76e289be23313cc3d33 on gokulsoumya:best-match-if-matches-overlap into f3817ebdf707807e00cde190061d8efc014d6057 on amjith:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 184173860e372da87b5bb76e289be23313cc3d33 on gokulsoumya:best-match-if-matches-overlap into f3817ebdf707807e00cde190061d8efc014d6057 on amjith:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 184173860e372da87b5bb76e289be23313cc3d33 on gokulsoumya:best-match-if-matches-overlap into f3817ebdf707807e00cde190061d8efc014d6057 on amjith:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling ff1444618c682fdddeed74db3e55e125047bfe90 on gokulsoumya:best-match-if-matches-overlap into f3817ebdf707807e00cde190061d8efc014d6057 on amjith:master.

amjith commented 6 years ago

That's a very nice addition.

Nicely done!

:ship:

sudormrfbin commented 6 years ago

Thanks 😊