How to search word by word in android

后端 未结 5 2078
我在风中等你
我在风中等你 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 08:55

    List tokens = new ArrayList();
    
    String text = "Samsung Galaxy S Two";
    StringTokenizer st = new StringTokenizer(text);
    
        //("---- Split by space ------");
        while (st.hasMoreElements()) {
            tokens.add(st.nextElement().toString());
        }
    
        String search = "axy";
        for(int i=0;i Remove Break if you want to continue searching all the words which contains `axy`
            }
        }
    
    output====>Galaxy
    

提交回复
热议问题