现成汉字字符串的模糊查找函数
来源:互联网 发布:淘宝清仓甩货图 编辑:程序博客网 时间:2024/04/30 23:46
参见:http://www.vccode.com/file_show.php?id=2457#xx1931xx
而且我给出了 BlurFindStr 函数的改进:
<code>
BOOL BlurFindStr(CString& strSource, CString& strFindCell)
{
int nLenCell = strFindCell.GetLength();
int nLenSource = strSource.GetLength();
if(nLenCell < 1)
return TRUE;
if(nLenSource <1)
return FALSE;
strSource.MakeLower();
strFindCell.MakeLower();
int i = 0; // 正在处理的strSource的下标
while(i < nLenSource)
{
int ii = i; // 保存一个备份
int j=0; // 正在处理的strFindCell的下标
// strSource 的递增量(如果当前是中文,则为2;否则,则为1)
int increment = (strSource.GetAt(ii) & 0x80)? 2 : 1;
while(j < nLenCell)
{
// 都是汉字
if(((strSource.GetAt(ii) & 0x80)) && ((strFindCell.GetAt(j) & 0x80)))
{
if (strSource.GetAt(ii) == strFindCell.GetAt(j) && strSource.GetAt(ii+1) == strFindCell.GetAt(j+1))
{
ii = ii + 2;
j = j + 2;
}
else
{
i = i + increment;
break;
}
}
// strSource是汉字
else if(((strSource.GetAt(ii) & 0x80)) && (!(strFindCell.GetAt(j) & 0x80)))
{
if (IsBlur(strSource.GetAt(ii), strSource.GetAt(ii+1), strFindCell.GetAt(j)))
{
ii = ii + 2;
j = j + 1;
}
else
{
i = i + increment;
break;
}
}
// strFindCell是汉字
else if((!(strSource.GetAt(ii) & 0x80)) && ((strFindCell.GetAt(j) & 0x80)))
{
i = i + increment;
break;
}
// 都不是汉字
else if((!(strSource.GetAt(ii) & 0x80)) && (!(strFindCell.GetAt(j) & 0x80)))
{
if (strSource.GetAt(ii) == strFindCell.GetAt(j))
{
ii++;
j++;
}
else
{
i = i + increment;
break;
}
}
}
if (j >= nLenCell) return TRUE;
}
return FALSE;
}
</code>
欢迎讨论,good luck!!
- 现成汉字字符串的模糊查找函数
- C# 现成能用的字符串加密、解密函数
- C# 现成能用的字符串加密、解密函数
- 字符串匹配/模糊匹配(查找/模糊查找)的算法
- C#中string字符串的模糊查找
- C++现成的hash函数
- 汉字的字符串查找及匹配
- 怎么把数组转化成字符串呢?有没有现成的函数呢?
- SQL 模糊查询 模糊查找 字符串匹配
- IOS字符串模糊查找算法
- JAVA反射机制(现成的函数)
- 一个返回汉字字符串各个汉字首字母串的函数
- 自动识别汉字的PHP截取字符串函数
- 支持汉字的字符串截取函数 substr_for_gb2312
- 查找字符/字符串的函数
- 一个字符串查找的函数
- datetime 的模糊查找
- datetime 的模糊查找
- 批处理JDBC语句以提高处理速度
- Oracle数据库几种关闭方式
- JavaScript跳转菜单(一级,二级,三级)
- 上班一族“黑话”辞典大曝光
- 今天终于有了一个结果!!
- 现成汉字字符串的模糊查找函数
- 中国报纸今年"十大流行语"发布:虐俘和审计风暴
- JAVA学习笔记之JIRA
- WebServices 效率之贴士
- 第三次迭代结束
- 1000的阶乘的处理
- 项目管理的中庸
- 人类登月35周年
- 自从盘古开天地 中国一共有多少神仙?