You need to sign in to do that
Don't have an account?
krishna1
How to Remove some text from string
Hi all,
we want get only 80 characters from string. If sting have above 80 characters, get only 80 characters from string. How to Remove last characters.
Thank you
Krishna
Hi
You can use str.left(80).
i.e. String str = 'fdsafdsafdsfdsfdsaf';
system.debug('>>>>' + str.left(80));
here you need not to check lenght of str.
You can also use Substring method.
i.e System.debug('>>>>' + str.substring(0,80));
but it will generate error is length of str is less than 80 so you need to check length before using this
All Answers
Hi
You can use str.left(80).
i.e. String str = 'fdsafdsafdsfdsfdsaf';
system.debug('>>>>' + str.left(80));
here you need not to check lenght of str.
You can also use Substring method.
i.e System.debug('>>>>' + str.substring(0,80));
but it will generate error is length of str is less than 80 so you need to check length before using this
String myString = originalString.substring(0,80);
The myString now has the first 80 characters.
Hope this helps!
Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.
Regards,
Satish Kumar