Contact Us 1-800-596-4880

levenshteinDistance

levenshteinDistance(a: String, b: String): Number

Returns the Levenshtein distance (or edit distance) between two strings.

Introduced in DataWeave version 2.4.0.

Parameters

Name Description

a

The first string.

b

The second string.

Example

This example shows how levenshteinDistance behaves with different strings.

Source

%dw 2.0
import levenshteinDistance from dw::core::Strings
output application/json
---
"kitten" levenshteinDistance "sitting"

Output

3