Consider the following string,
Input:
Only for Salesforce
I need to get the desired output like,
Output:
Only = String 1
For salesforce = String 2
If you want to split string on the first white space means
consider the following method,
- String str =’Only for Salesforce’;
- String str1,str2;
- str1=str.substring(0,str.indexOf(' '));
- str2=str.substring(str.indexOf(' ')+1);
- system.debug(‘String 1 ## ' + str1); // returns Only
- system.debug('String 2 ##' + str2); // returns for Salesforce
No comments:
Post a Comment