function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Surender reddy SalukutiSurender reddy Salukuti 

How can i get integer value and Decimal value from string

HI all,
I have one requrement 
string str1 = 'Commercial-(Aug)Quoted-Count300Premium - 250.00-Sarah Orosc';
string str2= 'Commercial-(Aug)Quoted-Count500Premium - 350.00-Sarah Orosc';
from the above two string from first one i need only integer value i.e : 300 only after getting the value i need to repalce that number with another number in the str 1name .
from second string i need only Decimal value i.e 350.00 only after getting the value i need to repalce that number with another number in the str 2name .

how can i do this please help me on this 

 

AbhinavAbhinav (Salesforce Developers) 
Hi Surender,

Check different suggestions provided on below link. 

https://salesforce.stackexchange.com/questions/42003/how-to-extract-a-number-from-a-string

If it helps, mark it as best answer.

Thanks!
Suraj Tripathi 47Suraj Tripathi 47
Hi Surender reddy Salukuti,

You can use this for getting Integer values from Sting.
Integer.valueof(str.trim());

If you find your Solution then mark this as the best answer.

Thank you!

Regards,
Suraj Tripathi