我如何在另一个字符串中搜索字符串?
这是我所说的一个例子:
String word = "cat";
String text = "The cat is on the table";
Boolean found;
found = findInString(word, text); //this method is what I want to know
Run Code Online (Sandbox Code Playgroud)
如果字符串"word"在字符串"text"中,则方法"findInString(String,String)"返回true,否则返回false.
如何判断字符串对象中是否存在子字符串"template"(例如)?
如果它不是一个区分大小写的检查,那就太好了.
假设我有一些字符串表,有几个字符串(如母亲,父亲,儿子),现在在这个字符串表中我想找到包含字符串"th"的每个单词.
我该怎么办?方法string.equals(string)在这里没有帮助.