title: Use regular expression to mask last 4 digit in Java
body: <p>I would like to mask the last 4 digits of the identity number (hkid)
  A123456(7) -> A123***(*)</p>
  
  <p>I can do this by below:</p>
  
  <pre><code>hkid.replaceAll("\\d{3}\\(\\d\\)", "***(*)")
  </code></pre>
  
  <p>However, can my regular expression really can match the last 4 digit and replace by "*"?</p>
  
  <pre><code>hkid.replaceAll(regex, "*")
  </code></pre>
  
  <p>Please help, thanks.</p>
  
  <p>Jessie</p>