title: REGEX to mask all characters except the first and last character
body: <p>I want to mask all the characters of a string except the first and last character. I tried something like this:</p>
  
  <pre><code>&lt;?php
  $count = 0;
  $string='asdfbASDF1234';
  echo preg_replace('/(?!^)\S/', '*', $string, -1 , $count);
  ?&gt;
  </code></pre>
  
  <p>It is masking all characters except the first one. What is the proper regex for this?</p>