title: JAVA - replaceAll in a regex with $1
body: <p>On a CodeFight problem it is asked to extract the first digits of a String and return it as a string, return null if it doesn't start with digits.</p>
  
  <p>I used regex, no problem, yet I don't understand very well the top answer :</p>
  
  <pre><code>String longestDigitsPrefix(String inputString) {
      return inputString.replaceAll("^(\\d*).*","$1");
  }
  </code></pre>
  
  <p>If somebody can explain that'd be awesome :)</p>