C的“std :: string :: find_first_of”等效于Java

C的“std :: string :: find_first_of”等效于Java,第1张

概述C的“std :: string :: find_first_of”是否有任何 Java等价物? string string1( "This is a test string!"); int location = string1.find_first_of( "aeiou" ); //location is now "2" (the position of "i") 实现同样功能的最简单方法是 C的“std :: string :: find_first_of”是否有任何 Java等价物?

string string1( "This is a test string!"); int location = string1.find_first_of( "aeIoU" ); //location is Now "2" (the position of "i")

实现同样功能的最简单方法是什么?

编辑:建议的解决方案也必须适用于AndroID.

解决方法 不使用外部库:

String string = "This is a test string!";     String letters = "aeIoU";     Pattern pattern = Pattern.compile("[" + letters + "]");     Matcher matcher = pattern.matcher(string);     int position = -1;     if (matcher.find()) {         position = matcher.start();     }     System.out.println(position); // prints 2
总结

以上是内存溢出为你收集整理的C的“std :: string :: find_first_of”等效于Java全部内容,希望文章能够帮你解决C的“std :: string :: find_first_of”等效于Java所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1224471.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-05
下一篇2022-06-05

发表评论

登录后才能评论

评论列表(0条)

    保存