title: How can i get String result in stringPattern value birdantantcatbirdcat
body: <p>i have dataDic that is an array {"ant","bird","cat"}</p>
  
  <p>dataDic is array of word that i want to search on stringPattern </p>
  
  <p>I want to use dataDic to get word result from stringPattern = birdantantcatbirdcat</p>
  
  <p>Ex1.
  dataDic = {"ant","bird","cat"}
  answer is {bird,ant,ant,cat,bird,cat}
  Ex2.
  dataDic = {"ant","cat"}
  answer is {ant,ant,cat,cat}</p>
  
  <p>this is my code
  `private static String stringTest="birdantantcatbirdcat";
      private static List dicListWord;
      private static ListresultString = new ArrayList&lt;>();</p>
  
  <pre><code>public static void main(String[] args) {
  
      dicListWord = new ArrayList&lt;&gt;();
      dicListWord.add("ant");
      dicListWord.add("bird");
      dicListWord.add("cat");
      String[] data = stringTest.split("");
  
      for (String dataDic:dicListWord) {
          String [] wordList = dataDic.split("");
          String foundWord = "";
          for (String charTec:data) {
              for (String dicWord:wordList) {
                  if(charTec.equals(dicWord)){
                      foundWord = foundWord.concat(charTec);
                      if(dataDic.equals(foundWord)){
                          resultString.add(foundWord);
                          foundWord = "";
                      }
                  }
              }
          }
      }
  
      for (String w1:data) {
          for (String result:resultString) {
                  System.out.println(result);
          }
      }
  }`
  </code></pre>
  
  <p>///////////////////////////////////////////////////////////////////////////////</p>
  
  <p>and Result that i run is </p>
  
  <p>{ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,antbird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird,ant,ant,bird,bird}</p>