I am writing a groovy program. I have an output like below
red 5green 5blue 10white 15
I want to sum up the digits in the output. The sum would be 35
I wrote the below logic however the program returned 17 which is right as the below logic takes into account digits.
can you please guide me as to how I make the program understand two digit numbers? so that i get the right sum?
for (int i =0; i < output.length(); i++)
{
{
sum=sum+Character.getNumericValue(grps.charAt(i))
}
}
Thanks