title: Check for multiple occurrence of certain character in string
body: <p>Edit: To those who downvote me, this question is difference from the duplicate question which you guy linked. The other question is about returning the indexes. However, for my case, I do not need the index. I just want to check whether there is duplicate.</p>
  
  <p>This is my code:</p>
  
  <pre><code>        String word = "ABCDE&lt;br&gt;XYZABC";
          String[] keywords = word.split("&lt;br&gt;");
          for (int index = 0; index &lt; keywords.length; index++) {
              if (keywords[index].toLowerCase().contains(word.toLowerCase())) {
                  if (index != (keywords.length - 1)) {
                      endText = keywords[index];
                      definition.setText(endText);
                  }
              }
  </code></pre>
  
  <p>My problem is, if the <code>keywords</code> is "ABC", then the string <code>endText</code> will only show "ABCDE". However, "XYZABC" contains "ABC" as well. How to check if the string has multiple occurrence? I would like to make the <code>definition</code> textview become <code>definition.setText(endText + "More");</code> if there is multiple occurrence.</p>
  
  <p>I tried this. The code is working, but it is making my app very slow. I guess the reason is because I got the String <code>word</code> through <code>textwatcher</code>.</p>
  
  <pre><code>        String[] keywords = word.split("&lt;br&gt;");
          for (int index = 0; index &lt; keywords.length; index++) {
              if (keywords[index].toLowerCase().contains(word.toLowerCase())) {
                  if (index != (keywords.length - 1)) {
                      int i = 0;
                      Pattern p = Pattern.compile(search.toLowerCase());
                      Matcher m = p.matcher( word.toLowerCase() );
                      while (m.find()) {
                          i++;
                      }
                      if (i &gt; 1) {
                          endText = keywords[index];
                          definition.setText(endText + " More");
                      } else {
                          endText = keywords[index];
                          definition.setText(endText);
                      }
                  }
              }
          }
  </code></pre>
  
  <p>Is there any faster way?</p>