How to check if a string has multiple values?


Good evening everyone!

I have the following doubt and it is that I am trying to verify that a string contains several values, that is, the following URL

Well, I would like to create a condition that says that it contains the word basketball and results, right?

For now the most I have achieved has been to check if the url contains the word basketball, that is, with a contains.

String phrase = "baloncesto";
        String url = "https:://";
asked by jc1992 22.04.2018 в 21:59

1 answer


Try this should work for you:

  String[] phrase = {"baloncesto", "resultado"};
    String url = "https:://";
    boolean contains = true;
    int i = 0;
    while(contains && i < phrase.length)
        contains = url.contains(phrase[i++]);
answered by 22.04.2018 / 22:26