
下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
<% ' copyright (c) 2009,reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution license. To vIEw ' a copy of this license,visit http://creativecommons.org/licenses/by/3.0/ or ' send a letter to Creative Commons,559 Nathan Abbott Way,Stanford,California ' 94305,USA. ' http://en.wikipedia.org/wiki/Soundex ' Calculate soundex code for entire strings,and soundex digits for indivIDual characters. ' REQUIRES: str_pad() function soundex(someString) dim result ' Rather than write a separate function to convert consonants to digits,I decIDed to overload the soundex function. if len(someString) = 1 then ' Calculate soundex digit for an indivIDual character. select case lcase(someString) case "b","f","p","v" soundex = "1" case "c","g","j","k","q","s","x","z" soundex = "2" case "d","t" soundex = "3" case "l" soundex = "4" case "m","n" soundex = "5" case "r" soundex = "6" case else ' Remove vowels right away instead of during a later step. soundex = "" end select else ' Calculate soundex code for an entire string. ' The first letter remains intact. result = ucase(left(someString,1)) ' Replace consonants with digits and remove vowels. for i = 2 to Len(someString) result = result & soundex(mID(someString,i,1)) next ' Collapse adjacent IDentical digits into a single digit of that value. for i = 1 to 6 do until inStr(result,cStr(i & i)) = 0 result = replace(result,cStr(i & i),cStr(i)) loop next ' Return the starting letter and the first three remaining digits. ' If needed,append zeroes to make it a letter and three digits. soundex = str_pad(left(result,4),4,"0",STR_PAD_RIGHT) end if end function%>
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的Soundex全部内容,希望文章能够帮你解决Soundex所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)