前端拼音模糊搜索

前端实现拼音模糊搜索
pinyin-match
[https://github.com/xmflswood/...[1]前端

const PinyinMatch = require('pinyin-match');
let test = '123曾经沧海难为水除却巫山不是云'git

PinyinMatch.match(test, '23曾'); // [1, 3]github

PinyinMatch.match(test, 'cjc') // [3, 5]ui

PinyinMatch.match(test, 'cengjingcanghai') // [3, 6]get

PinyinMatch.match(test, 'cengjingcangha') // [3, 6]it

PinyinMatch.match(test, 'engjingcanghai') // falsetest

PinyinMatch.match(test, 'zengjingcang') // [3, 5]require

PinyinMatch.match(test, 'sdjkelwqf') // false搜索

PinyinMatch.match(text, 'zengji ng cang') // [3, 5]gc

PinyinMatch.match(text, 'zengji ng cangsdjfkl') // false

PinyinMatch.match(' 我 爱你 中 国 ', 'nzg') // [6, 12]

PinyinMatch.match(' 我 爱你 中 国 ', '爱你中') // [5, 8]

相关文章
相关标签/搜索