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.
I used regex, no problem, yet I don't understand very well the top answer :
String longestDigitsPrefix(String inputString) {
return inputString.replaceAll("^(\\d*).*","$1");
}
If somebody can explain that'd be awesome :)