You need to sign in to do that
Don't have an account?
V100
Problems with substring
I have a text field that i want to trim and have been trying with substring:
Field_Name__c.substring(5,27);
However i get errors
System.StringException: Ending position out of bounds: 28
When the field is less than 32 characters. It works fine if i say (5,10) as all have at least 15 characters.
Any tips on how i can trim this to ignore the first 5 characters and then return no more than 27 after that.
All Answers
Excellent thanks, worked perfectly
You can also try using trim() function. Sample code is given below :
function Trim(str)
{
while (str.substring(0,1) == ' ') // check for white spaces from beginning
{
str = str.substring(1, str.length);
}
while (str.substring(str.length-1, str.length) == ' ') // check white space from end
{
str = str.substring(0,str.length-1);
}
return str;
}