title: Masking part of the string with a regex
body: <p>The idea is to mask a string like it's done with a credit cards. It can be done with this one line of code. And it works. However I can't find any straightforward explanations of the regex used in this case.</p>
  
  <pre><code>public class Solution {
      public static void main(String[] args) {
  
          String t1 = "518798673672531762319871";
          System.out.println(t1.replaceAll(".(?=.{4})", "*"));
      }
  }
  </code></pre>
  
  <p>Output is: <code>********************9871</code></p>