Skip to content

Searches a haystack for all best possible matches of needle, returning their position and Levenshtein distance.

License

Notifications You must be signed in to change notification settings

Attibee/AttibeeJS-Fuzzy-Substring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AttibeeJS Fuzzy Substring

Searches a haystack for all best possible matches of needle, returning their position and Levenshtein distance.

Installation

npm install @attibee/fuzzy-substring

Usage

var FuzzySubstring = require('@attibee/fuzzy-substring');
var needle = 'apple';
var haystack = 'app1e potato appIe';

//search haystack for needle
var results = new FuzzySubstring().getMatches('apple', 'app1e potato apble');

//output results
for(let result of results) {
    var substring = haystack.substring(result.start, result.end);
    var distance = result.distance;
    
    console.log('Distance: ' + distance + '  Match: ' + substring);
}

// Output:
// Distance: 1  Match: app1e
// Distance: 1  Match: appIe

About

Searches a haystack for all best possible matches of needle, returning their position and Levenshtein distance.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published