How to search word by word in android

后端 未结 5 1986
我在风中等你
我在风中等你 2021-01-22 08:28

How to search a word in a string?

For example

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

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

5条回答
  •  野的像风
    2021-01-22 09:12

    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
    }
    

提交回复
热议问题