File Exchange

image thumbnail

Fuzzy Search

version (6.8 KB) by Eduard Polityko
The function finds substrings of a reference string that match a pattern string approximately


Updated 02 Mar 2018

View License

Function fzsearch(r,p,n,case) finds the best or predetermined approximate matching between substrings of a string r (reference) and a string p (pattern). The Levenshtein distance is used as a measure of matching. Levenshtein distance is the minimum number of single-character substitutions, deletions and insertions required to convert string A to string B. It is possible to search both for case sensitive and insensitive.
Results of a search are a distance of matching and indices of the ends of reference substrings. For the best match, the function allows to determine also the substrings themselves.

Cite As

Eduard Polityko (2020). Fuzzy Search (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Eduard Polityko

Hi Pietro,
The function is not intended for cells, but only for strings (see description). It would probably be reasonable to provide an error message when using cells.
Thank you for your attention and high rating.


Hi Eduard, the function is really great. I am signaling that when the function is with a cell array, like the following:
[d a]=fzsearch(str,'ab')

a is a cell array of 10 elements instead of 2. All the elements from 2 to 5 and from 7 to ten are empty.

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux