title: What is the correct usage of replace by regex in Angular4 Template?
body: <p>I have a requirement of masking SSN. So, I did the following changes:</p>
  
  <pre><code>&lt;ng-container *ngIf="user.ssn.length != 4"&gt;
    {{ user.ssn ? user.ssn.replace(/[0-9]{3}-{0,1}[0-9]{2}/, "#") : null }}
  &lt;/ng-container&gt;
  </code></pre>
  
  <p>but replace by regular expression throws me exception:</p>
  
  <blockquote>
    <p>Uncaught Error: Template parse errors: Parser Error: Unexpected token
    / at column 62 in [
                      {{ user.ssn ? user.ssn.replace(/[0-9]{3}-{0,1}[0-9]{2}/, "#") : null }}</p>
  </blockquote>
  
  <p>If I use a strinf instead of regex, I don't get any errors. But, as it's not possible to determine exactly what to replace, I needed to use regex.</p>
  
  <p>How can I correct this?</p>