How to check if a string has multiple values?

1

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

https://www.mismarcadores.com/baloncesto/espana/leb-plata/resultados/

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:://www.mismarcadores.com/baloncesto/espana/leb-plata/resultados/";
        System.out.println(url.contains(phrase));
    
asked by jc1992 22.04.2018 в 21:59
source

1 answer

2

Try this should work for you:

  String[] phrase = {"baloncesto", "resultado"};
    String url = "https:://www.mismarcadores.com/baloncesto/espana/leb-plata/resultados/";
    boolean contains = true;
    int i = 0;
    while(contains && i < phrase.length)
        contains = url.contains(phrase[i++]);
    System.out.println(contains);
    
answered by 22.04.2018 / 22:26
source