Pinyin fuzzy match not completed

Source: Internet
Author: User

[Csharp]
Private bool IsPinyinMatch (char [] keys, char [] destination)
{
Int I = 0, j = 0;
While (I <keys. Length & j <destination. Length)
{
If (keys [I] = destination [j])
{
I ++;
If (I = keys. Length) return true;
}
J ++;
} Www.2cto.com
Return false;
}
Private bool IsPinyinMatch (String keys, String destination)
{
Return IsPinyinMatch (keys. ToCharArray (), destination. ToCharArray ());
}

Private bool IsPinyinMatch (char [] keys, char [] destination)
{
Int I = 0, j = 0;
While (I <keys. Length & j <destination. Length)
{
If (keys [I] = destination [j])
{
I ++;
If (I = keys. Length) return true;
}
J ++;
}
Return false;
}
Private bool IsPinyinMatch (String keys, String destination)
{
Return IsPinyinMatch (keys. ToCharArray (), destination. ToCharArray ());
}


Test example: Enter key1 = "WM", Match: key2 = "wanmeiqianzhuan"

First, use W of key1 to match the first character in Key2. If no match is found, J ++ continues to match the second character in Key2. If the first item is matched, I ++ continues to use the second position of key1 to match the J position of the Key.

.

If key1 is equal to the length of I, and the last digit of key1 matches in key2, return true.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.