title: angularjs: mask the first five digits of SSN
body: <p>I'm trying to mask the first 5 digits of SSN using a filter which should look something like this 
   <code>XXX-XX-1234</code></p>
  
  <p>What I came up with so far:</p>
  
  <pre><code>// &lt;td&gt;{{SocialSecurityNumber | ssn}}
  
  angular.module('ng').filter('ssn', function () {
      return function (ssn) {
          if (!ssn) {
              return '';
          }
  
          var value = ssn.toString().trim().replace(/^\+/, '');
  
          if (value.match(/[^0-9]/)) {
              return ssn;
          }
  
          return (ssn.slice(0, 3).replaceWith('*') + '-' + ssn.slice(4, 5).replaceWith('*') + '-' + ssn.slice(4)).trim();
      };
  });
  </code></pre>