For a string like :
String strTest = '123456.78';
system.debug(StrTest.split('\\.'));
The result is
USER_DEBUG [2]|DEBUG|(123456, 78)
How can I get the individual length of the splitted parts ?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityFor a string like :
String strTest = '123456.78';
system.debug(StrTest.split('\\.'));
The result is
USER_DEBUG [2]|DEBUG|(123456, 78)
How can I get the individual length of the splitted parts ?
The string split()
method returns a List<String>
, so getting the individual lengths is simply
string.length()
on the individual stringsHere you go. Logic is same as Derek's answer
String strTest = '123456.78';
List<String> str = strTest.split('\\.');
for(integer i=0;i<str.size(); i++)
{
System.debug(str[i].length());
}