如何在android中查找字符串中的指定文本?
我有一个字符串对象,我需要检查它是否包含另一个字符串。这就像检查“Hello World”是否包含世界“World”如何在android中查找字符串中的指定文本?,android,Android,我有一个字符串对象,我需要检查它是否包含另一个字符串。这就像检查“Hello World”是否包含世界“World” 我该怎么做呢?如果您只想检测源字符串中是否包含特定字符串,您可以这样做 String source=“这里是字符串“hellohowareyou”,我想提取世界“how”…这可能是怎么回事???? 安卓” If(source.contains(“此处是”)) ..... 其他的 ..... 试试这个。。。为我工作。。。。 使用关键字 包含 及 toLowerCase() 你可以
我该怎么做呢?如果您只想检测源字符串中是否包含特定字符串,您可以这样做
String source=“这里是字符串“hellohowareyou”,我想提取世界“how”…这可能是怎么回事????
安卓”
If(source.contains(“此处是”))
.....
其他的
.....
试试这个。。。为我工作。。。。
使用关键字
包含
及
toLowerCase()
你可以实现你想要的解决方案。。。这边
String text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.";
if(text .toLowerCase().contains(text.toLowerCase())){
}
else {
}
试试这个
String text = "Hello World.";
if(text.contains("World')){
//Do something
}
else {
//Do something
}
可能重复的