Move all digits to the beginning of a given string | Java program for the above approach ; Function to move all the digit at the beginning of the string ; Replace all the non - numeric characters with " ▁ " and replace all digits with " ▁ " ; Print the string ; Driver Code ; Given String str
class GFG { static void moveAllDigitAtBeginning ( String str ) { String moveAllDigit = str . replaceAll ( " \\ D + " , " " ) + str . replaceAll ( " \\ d + " , " " ) ; System . out . println ( moveAllDigit ) ; } public static void main ( String args [ ] ) { String str = " GeeksforGeeks1234" ; moveAllDigitAtBeginning ( str ) ; } }