Open menu dropdown
useStringMatching
Reactive similarity of two whole strings (score from 0 to 1, case and accents ignored, Levenshtein distance) and whether they match above a threshold - to detect a close spelling. To search in a list, use useFuzzySearch.
TIP
It compares two whole strings, with the Levenshtein distance: a short query is far from a long text ("fra" and "France" do not match). To search a query in a list, use useFuzzySearch.
Usage
Enter first string
Enter second string
isMatching: true
score: 0.8333333333333334
vue
<script lang="ts" setup>
import { useStringMatching } from 'maz-ui/composables'
import { ref } from 'vue'
const string1 = ref<string>('maz-ui')
const string2 = ref<string>('màéz-uiok')
const { score, isMatching } = useStringMatching(string1, string2)
</script>
<template>
<MazInput v-model="string1" label="Enter first string" />
<MazInput v-model="string2" label="Enter second string" />
<p>
<b>isMatching:</b> {{ isMatching }}
</p>
<p>
<b>score:</b> {{ score }}
</p>
</template>