How to search word by word in android

后端 未结 5 1736
日久生厌
日久生厌 2021-01-22 08:20

How to search a word in a string?

For example

String text = \"Samsung Galaxy S Two\";

If I use text.contains(\"???\");<

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 08:55

    I know this is an old question, but I am writing here so that the next person who needs help can be helped.

    You can use matches.

    String str = "Hello, this is a trial text";
    str1 = str.toLowerCase();
    if(str1.matches(".*trial.*")) //this will search for the word "trial" in str1
    {
        //Your Code
    }
    

提交回复
热议问题