在另一个字符串中搜索一个字符串 [英] Searching for one string in another string
本文介绍了在另一个字符串中搜索一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一些String表,它有几个字符串(比如母亲,父亲,儿子),现在在这个字符串表中,我想找到包含字符串th的每个单词。
Let's say I have String Table that have a few strings (like mother, father, son) and now in this String Table I want to find every word that contains string "th" for example.
我该怎么办?方法string.equals(string)在这里没有帮助。
How should I do it? Method string.equals(string) won't help here.
推荐答案
使用包含或 indexOf 方法,取决于你是否需要这个职位。
Use the contains or indexOf methods, depending on whether you need the position.
这篇关于在另一个字符串中搜索一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文