0

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 ?

2
  • what you like to see, can you update your question Feb 4, 2017 at 4:10
  • do you want 5 and 2? Feb 4, 2017 at 4:10

2 Answers 2

1

The string split() method returns a List<String>, so getting the individual lengths is simply

  1. Iterating over the returned list
  2. calling string.length() on the individual strings
1

Here 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());
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .