/** * Purpose:不能與已知的字符串相同或部分相同 * @author Hermanwang * @param str : 要比較的字符串 * @param input : 輸入的字符串 * @return Boolean : 檢核結果 */ public static boolean inputSameAsStr(String str, String input) { //全都轉化為小寫 String strLower = str.toLowerCase(); String inputLower = input.toLowerCase(); //反转 String strReverseLower = new StringBuffer(strLower).reverse().toString(); boolean same = true; int strLength = str.length(); int inputLength = input.length(); if (strLength >= 3 && inputLength >= 3) { String newStr; for (int j = 0; j < inputLength; j ++) { newStr = inputLower.substring(j,j+3); if (strLower.indexOf(newStr) >= 0 || strReverseLower.indexOf(newStr) >= 0) { same = false; break; } if (j + 3 >= inputLength) { break; } } } return same; }
验证字符串與已知的字符串相同或部分相同
最新推荐文章于 2021-12-24 10:41:27 发布
本文介绍了一种用于比较输入字符串与已知字符串是否相似的算法。该算法通过将字符串转换为小写并反转,然后检查已知字符串及其反转形式是否包含输入字符串的任意连续三个字符来判断两者是否相似。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Wan2.2-T2V-A5B
文生视频
Wan2.2
Wan2.2是由通义万相开源高效文本到视频生成模型,是有50亿参数的轻量级视频生成模型,专为快速内容创作优化。支持480P视频生成,具备优秀的时序连贯性和运动推理能力
4832

被折叠的 条评论
为什么被折叠?



