There is a string "REMBO IUI Z &&", how can I check for the presence of characters &&

  • If you are given an exhaustive answer, mark it as accepted. - Suvitruf

4 answers 4

The String class defines the int indexOf(String sub) method int indexOf(String sub)

 String s = "dkdbd&&dgs", sub = "&&"; if (s.indexOf(sub) != -1) //элемент есть else //подстроки нет 
     public static boolean contains(String str, String substr){ return str.contains(substr); } contains("REMBO IUI Z&&", "&&"); 

    Or regular:

     public static boolean contains(String pattern, String content) { return content.matches(pattern); } contains("(.*)&&(.*)", "REMBO IUI Z&&") 
       String s = "REMBO IUI Z&&"; if (s.contains("&&")) { // действие } 

        using contains for example.
        documentation