approx-string-match-js
approx-string-match-js copied to clipboard
Missing some matches?
I tried calling search("before quote after", "...quote...", 6), and I got this output:
[
{
"start": 4,
"end": 12,
"errors": 6
},
{
"start": 4,
"end": 13,
"errors": 6
},
{
"start": 4,
"end": 14,
"errors": 6
},
{
"start": 4,
"end": 15,
"errors": 6
}
]
Basically the first match is "re quote", when I'd really just like "quote" as the match. I can see that they're the same edit distance, but the one with the lowest length is what we want in our use case because the pattern often has added surrounding formatting that isn't in the text.
I was surprised that {"start": 7, "end": 12, "errors": 6} ("quote") wasn't there. It seems like this algorithm only returns some of the best matches. Is that a known limitation?