Brian Dunning's FileMaker Custom Functions

Levenshtein ( str1 ; str2 ; damerau ; caseSensitive )

Finds the Levenshtein or Damerau-Levenshtein distance between two strings.

  Average rating: 3.5 (72 votes) Log in to vote

Steve Allen   Steve Allen
Richard Carlton Consulting, Inc.
http://www.rcconsulting.com

  Sample input:
Levenshtein ( "Steve" ; "stephen" ; False ; True )
  Sample output:
4

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Finds the Levenshtein or Damerau-Levenshtein distance between two strings, as described at:

http://en.wikipedia.org/wiki/Levenshtein_distance

http://en.wikipedia.org/wiki/Damerau–Levenshtein_distance

(both pages accessed January 29, 2009 at 4:00 p.m.)

Note: best viewed in a large text space, or at least without word wrap, for formatting reasons.

 

Comments

Mrlaura   Mrlaura
Oct 11, 2026
Thanks, Steve, for sharing this FileMaker implementation and documenting the array-indexing approach.

One small issue I noticed: with `pad = "000"`, each matrix coordinate can only represent values from 0 to 999, rather than allowing strings up to 999,999 characters as described.

For example, `Right("000" & 1000; 3)` returns `"000"`, causing coordinate 1000 to collide with coordinate 0.

I'd suggest adding a length check to reject unsupported inputs, or increasing the padding width if longer strings are required. The same change would need to be applied consistently across the helper functions.

This reference discusses implementation correctness and memory considerations:

https://www.levenshtein.net/levenshtein-implementations

For transparency, I contribute to the linked reference.

Thanks again for making this implementation available!
 
Mrlaura   Mrlaura
Oct 11, 2026
Thanks, Steve, for sharing this FileMaker implementation and documenting the array-indexing approach.

One small issue I noticed: with `pad = "000"`, each matrix coordinate can only represent values from 0 to 999, rather than allowing strings up to 999,999 characters as described.

For example, `Right("000" & 1000; 3)` returns `"000"`, causing coordinate 1000 to collide with coordinate 0.

I'd suggest adding a length check to reject unsupported inputs, or increasing the padding width if longer strings are required. The same change would need to be applied consistently across the helper functions.

This reference on Levenshtein implementation correctness and performance discusses related considerations.

For transparency, I contribute to the linked reference.

Thanks again for making this implementation available!
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 22 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: