How to find a sequence of digits and multiply only those sequence of digits with number 2 in JAVA?
Let's say I have a string "My age is 19". How do I get a string "My age is 38" as the output?
Also, how do I reverse that multiplied number in the string later on. For above example input, the second output should be "My age is 83"
I tried using java.util.regex.Pattern. It works. However, is there any other way we can do that. Probably through converting the string into an array? I tried. But I am struck at multiplying sequence of characters in the string. Instead I am able to multiple each digit. But I want the sequence of digits to be multiplied by 2. For instance, in above example, I am able to multiply each digit 1 and 9 by 2. But I want 19 as a 2 digit number to be multiplied by 2.