Answers for "how to get all numbers from string java"

1

java isolate the numbers from string

// string contains numbers
        String str = "The price of the book is $49";
        // extract digits only from strings
        String numberOnly = str.replaceAll("[^0-9]", "");
        // print the digitts
        System.out.println(numberOnly);
Posted by: Guest on October-25-2021
0

how to extract digits from a number in java

// Java program to Extract Digits from A Given Integer
        // Printing the last digit of the number
        while (number > 0) {
            // Finding the remainder (Last Digit)
            int remainder = number % 10;
            // Printing the remainder/current last digit
            System.out.println(remainder);
            // Removing the last digit/current last digit
            number = number / 10;
        }
Posted by: Guest on January-31-2022

Code answers related to "how to get all numbers from string java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language