You need to sign in to do that
Don't have an account?
Priyangbada Basak 9
need to eliminate all the 1's from a number
I have used LEFT operator to get the first 1 from a number and remove it, for eg:
String number = '1111123456789';
number.LEFT(1) == '1'
String newNum = number.SUBSTRING(1);
Now i need to eliminate all the '1' that are present from the starting, so my output number would come as 23456789 and it would remove all the 1's present from first,in the example String number.
Thanks Shruthi...it worked but i forgot to mention that if 1 is in between any number, that should be kept...as in
if String num1 = '11115671245510'
then after eliminating the 1's from the left, output should be = 5671245510.
So i used below code and it worked for me.
String num1 = '11113451678';
Integer i;
String newNum;
for (i=0; i<=num1.length(); i++){
if(num1.LEFT(1) == '1'){
newNum = num1.SUBSTRING(1);
num1 = newNum;
}
}
All Answers
Thanks Shruthi...it worked but i forgot to mention that if 1 is in between any number, that should be kept...as in
if String num1 = '11115671245510'
then after eliminating the 1's from the left, output should be = 5671245510.
So i used below code and it worked for me.
String num1 = '11113451678';
Integer i;
String newNum;
for (i=0; i<=num1.length(); i++){
if(num1.LEFT(1) == '1'){
newNum = num1.SUBSTRING(1);
num1 = newNum;
}
}