approx-string-match-js icon indicating copy to clipboard operation
approx-string-match-js copied to clipboard

Missing some matches?

Open MichaelSnowden opened this issue 9 months ago • 3 comments

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?

MichaelSnowden avatar Feb 01 '25 07:02 MichaelSnowden