title: How do you match the individual words as separate words in the input sentence in a string that has just one word
body: <p>I want to see if multiple words found inside the string. With O(n^2) complexity. For example: sunshine - sun, shine, hine. And will print collection of strings: sun shine and hine if it matches.  How do I check if a string contains a matching words?</p>
  
  <pre><code>//String search = sunshine 
  public static boolean wordsInsideTheString(String search) { 
      String[] word = {"sun", "shine", "hine"};
      int counter = 0;    
      for(int i = 0; i &lt; word.length; i++) {      
         String[] words = word[i].split("\\s+");
         for (String check : words) 
             if(check.equalsIgnoreCase(search)) {
                 counter++;
                 break;
             } 
         }    
      return false;
  }
  </code></pre>
  
  <p>Calling the method with:</p>
  
  <pre><code>assert.True(wordsInsideTheString("sunshine");
  </code></pre>