title: Select2 Custom Matcher
body: <p>I'm trying to use a custom matcher with the select2 library.  Specifically, I want to return <code>other</code> as the not-found option, as well as only match from the beginning of a string.  I found the following to SO questions which answer each of these parts separately:</p>
  
  <p><a href="https://stackoverflow.com/questions/17950117/select2-when-no-option-matches-other-should-appear">Select2, when no option matches, &quot;other&quot; should appear</a></p>
  
  <p>and </p>
  
  <p><a href="https://stackoverflow.com/questions/15809594/jquery-select2-plugin-how-to-get-only-the-result-mystring">jquery select2 plugin how to get only the result &#39;myString%&#39;</a></p>
  
  <p>However, when I combine the two techniques, it is no longer matching properly.  My solution looks like:</p>
  
  <pre><code>$("#myForm").select2({
      minimumInputLength: 2,
      width: width,
      matcher: function(term, text) {
          // THIS IS WHERE I COMBINE THE METHODS
          return text === 'Other' || text.toUpperCase().indexOf(term.toUpperCase())==0;
      },
      sortResults: function(results) {
          if (results.length &gt; 1) results.pop();
              return results;
      }
  });
  </code></pre>
  
  <p>What am I doing wrong, and what is the proper way to make this matcher function?</p>