gpt4 book ai didi

java - 如何在java字符串中查找单词java中大小写连续的个数

转载 作者:行者123 更新时间:2023-12-02 09:39:47 25 4
gpt4 key购买 nike

skdoakdoakdoakdpoakdpoakdopkapodkoapdkpoakdpoakdpakpdkapdkpaodkpakdpakdpakdpkpdkadpkapdkpaoooooooooooooooooooooooooooooooooooooooooooooooooodksaodaodddddddddddddddddddddddddddddddddsdkaopdkpadpaokdakdopakdpakpdadksaopdoapkdpakdpoakdpokdkapodpadpakdpoakdopakdopkpoakdpapdkapdpadakdposaodpadpakdopakdpoakdpokpdkpakdopadkpakdkdkpadkakdpakdp

       String test1 = "java java java. JAVA! ";
String test2 = "h w !!! ...";
String word ="java";
int count = 0;

String strArray[] = test2.split(" ");

for(int i=0; i < strArray.length; i++){
if (word.equals("java")) {
`enter code here`
count++;
}
System.out.println(strArray[i]);
}

System.out.println(count);
test1.toUpperCase() + test1.toLowerCase().concat;
count++;
test1.toLowerCase();
count++;
System.out.println(count);

如何返回java中不区分大小写的出现次数我会在互联网上搜索但没有运气。在 JavaScript 中我会使用 are 但在这里我是新的所以请帮助。所以我需要按照上面的建议找到java不区分大小写发生了多少次

最佳答案

希望这有帮助

String inputString = "java java java. JAVA!";

int counter = 0;
Pattern pattern = Pattern.compile("JAVA");
Matcher match = pattern.matcher(inputString.toUpperCase());
while (match.find()) {
counter++;
}

System.out.println(counter);

关于java - 如何在java字符串中查找单词java中大小写连续的个数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57193983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com