title: SharePoint 2013 - Need to Split Names from a Multi-Select People Picker
body: <p>I'm working in SharePoint 2013, and I have created a custom display template for a Content Search Web Part. Three of my fields use multi-select people pickers, and all three are returning the names in one string as shown below:</p>
  
  <p>Brown, JohnSmith, MikeJones, Mary</p>
  
  <p>I want to return the names in the format shown below but I just can't seem to get it to work:</p>
  
  <p>Brown, John; Smith, Mike; Jones, Mary</p>
  
  <p>I've tried the advice from these blog articles:</p>
  
  <p><a href="https://social.msdn.microsoft.com/Forums/en-US/ea0fe2fe-0757-4c1c-b3cc-2dd99b38bfa1/sharepoint-2013-custom-display-template-people-picker-field-separate-multiple-names-in-display?forum=sharepointdevelopment" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/en-US/ea0fe2fe-0757-4c1c-b3cc-2dd99b38bfa1/sharepoint-2013-custom-display-template-people-picker-field-separate-multiple-names-in-display?forum=sharepointdevelopment</a></p>
  
  <p><a href="https://sharedpointtips.blogspot.com/2015/01/sharepoint-2013-display-template.html" rel="nofollow noreferrer">https://sharedpointtips.blogspot.com/2015/01/sharepoint-2013-display-template.html</a></p>
  
  <p><a href="http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display-templates-spc3000-spc14.aspx" rel="nofollow noreferrer">http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2014/02/26/useful-javascript-for-working-with-sharepoint-display-templates-spc3000-spc14.aspx</a></p>
  
  <p>I've tried all the suggestions included in the first article - <a href="https://social.msdn.microsoft.com/Forums/en-US/ea0fe2fe-0757-4c1c-b3cc-2dd99b38bfa1/sharepoint-2013-custom-display-template-people-picker-field-separate-multiple-names-in-display?forum=sharepointdevelopment" rel="nofollow noreferrer">https://social.msdn.microsoft.com/Forums/en-US/ea0fe2fe-0757-4c1c-b3cc-2dd99b38bfa1/sharepoint-2013-custom-display-template-people-picker-field-separate-multiple-names-in-display?forum=sharepointdevelopment</a></p>
  
  <p>In the Header:</p>
  
  <p><code>'Response Preparer'{Response Preparer}:'ResponsePreparerOWSUSER'</code></p>
  
  <p>In the body:</p>
  
  <pre><code>&lt;script&gt;
              $includeLanguageScript(this.url, "~sitecollection/_catalogs/masterpage/Display Templates/Language Files/{Locale}/CustomStrings.js");
          $includeScript(this.url, "~sitecollection/_catalogs/masterpage/Display Templates/Search/jquery-1.11.3.min.js");
          $includeScript(this.url, "~sitecollection/_catalogs/masterpage/Display Templates/Search/splitNames.js");
  
          RegisterSod('jquery-1.11.3.min.js', Srch.U.replaceUrlTokens("~sitecollection/_catalogs/masterpage/Display Templates/Search/jquery-1.11.3.min.js"));
          RegisterSod('splitNames.js', Srch.U.replaceUrlTokens("~sitecollection/_catalogs/masterpage/Display Templates/Search/splitNames.js"));
  
          //Register Dependencies
          RegisterSodDep('splitNames.js', 'jquery-1.11.3.min.js');
  
          AddPostRenderCallback(ctx, function () {
             EnsureScriptFunc("splitNames.js", 'splitNames', function() {
               var regulatorypartner = $getItemValue(ctx, "Regulatory Partner");
               var splitregpartner = "";
               splitregpartner = $splitNames(regulatorypartner);
             });
           });        
  
      &lt;/script&gt;
  </code></pre>
  
  <p>In the JavaScript section I have tried this:</p>
  
  <pre><code>var regulatorypartner = ctx.RegulatoryPartnerOWSUSER;
  var splitregpartner = splitNames(regulatorypartner);
  </code></pre>
  
  <p>This is my  display code:</p>
  
  <pre><code>&lt;td rowspan="2" colspan="4" style="text-align:center; border:0.5px solid #F88007;"&gt; _#= splitregpartner =#_ &lt;/td&gt;
  </code></pre>
  
  <p>The display should look like this:</p>
  
  <p>Brown, John; Smith, Mike; Jones, Mary</p>
  
  <p>Here is the output of regulatrypartner:</p>
  
  <p>Brown, JohnSmith, MikeJones, Mary</p>
  
  <p>Here is the splitNames code (file is included in the RegisterSod statement):</p>
  
  <pre><code>  var newStr="";
    for(var i=0;i&lt;str.length;i++){
      var char=str.charAt(i);
      if(char==char.toUpperCase()){
          newStr+=" "+char ;
      }else{
          newStr+=char;
  
      }
    }
    return newStr;
  }
  </code></pre>