Remove All 0's from Text

 

I'm trying to setup a function that will remove all 0's from a string. This is what I have so far:


int length=StringLen(text);
int index=StringFind(text,"0",0);
for(int x=index; x <= length; x++)
{
string cut=StringSetChar(difference,x,32);
}
string differencecut=StringTrimRight(cut);
string final=StringTrimLeft(differencecut);
Print(final);


Unfornately this is not working, anyone have any ideas about this?

 

How about this one:


string cuts, cut;
int length=StringLen(text);
int index=StringFind(text,"0",0);
for(int x = 0; x < length; x++)
{
while(x!=index)
{
cut=StringSetChar(text, 0, StringGetChar(text,x));
cuts = cuts + cut + " ";
}
}
string trimright=StringTrimRight(cuts);
string final=StringTrimLeft(trimright);

 

OK, I've created a working function:


int StripExtras(string text, string search1, string search2)
{
int length=StringLen(text) - 1;
while(length>=0)
{
int index=StringFind(text,search1,0);
int index2=StringFind(text,search2,0);
text=StringSetChar(text,index,32);
text=StringSetChar(text,index2,32);
length--;
}
return(StrToInteger(text));


This can be used to remove multiple characters and/or substrings from a string. I am using this to simplify a pip count from current price to SMA50 line.

Reason: