title: Not matching product names in the Array List in Java
body: <p>I have two array lists. </p>
  
  <p><strong>capturedForeginProduct</strong> : Foreign Product Names</p>
  
  <p><strong>capturedLocalProducts</strong> : Local Product Names</p>
  
  <p><strong>capturedForeginProduct</strong> Array lists contains following foreign product names.</p>
  
  <blockquote>
    <p>Washington Apple Drink</p>
    
    <p>Token Apple Drink</p>
    
    <p>Skinner Apple Drink</p>
  </blockquote>
  
  <p><strong>capturedLocalProducts</strong> Array list contains following local product names.</p>
  
  <blockquote>
    <p>SUNFRESH Apple Drink RTS 1L</p>
    
    <p>APPY FIZZ Sparkling Apple Drink</p>
    
    <p>APPY Apple Drink 250ml Pet Bottle</p>
  </blockquote>
  
  <p>I use the following code snippet to match the product names against <strong>capturedForeginProduct</strong> array list to the <strong>capturedLocalProducts</strong> array list.</p>
  
  <pre><code>if(capturedForeginProduct.get(i).equals(capturedLocalProducts.get(j)))  {
  </code></pre>
  
  <p>But it is not matching any of the products. Basically my final outcome should be like follows.</p>
  
  <blockquote>
    <p>Washington Apple Drink</p>
    
    <p>Token Apple Drink</p>
    
    <p>Skinner Apple Drink</p>
  </blockquote>
  
  <p>should match with,</p>
  
  <blockquote>
    <p>SUNFRESH Apple Drink RTS 1L</p>
    
    <p>APPY FIZZ Sparkling Apple Drink</p>
    
    <p>APPY Apple Drink 250ml Pet Bottle</p>
  </blockquote>
  
  <p>as each of the product contains "<strong>Apple</strong>" wording. I do not mind whether it contains capitals or not but if the word is available then it should match. </p>
  
  <p>This my code in order to carry out this particular task.</p>
  
  <pre><code>for (int i = 0; i &lt; capturedForeginProduct.size(); i++) {
  
      for (int j = 0; j &lt; capturedLocalProducts.size(); j++) {
          //   if(capturedForeginProduct.get(i).contains("Garlic")) {
          //  if (Pattern.compile(Pattern.quote(capturedLocalProducts.get(j)), Pattern.CASE_INSENSITIVE).matcher(capturedForeginProduct.get(i)).find() || capturedLocalProducts.get(j).toLowerCase().contains(capturedForeginProduct.get(i).toLowerCase())) {
  
          if (capturedForeginProduct.get(i).equals(capturedLocalProducts.get(j))) {
              //  if(capturedLocalProducts.get(i).equals("SUNFRESH Mango Drink RTS 1L"))  {
  
              log.debug("Matching Second Chance .. : " + "\t" + capturedForeginProduct.get(i) + "\t" + capturedLocalProducts.get(j));
              firstForeignProducts.add(capturedForeginProduct.get(i));
              firstLocalProducts.add(capturedLocalProducts.get(j));
          } else {
              log.debug("Un Matching Second Chance .. : " + "\t" + capturedForeginProduct.get(i) + "\t" + capturedLocalProducts.get(j));
          }
      }
  }
  </code></pre>
  
  <p>Thanks.</p>