How to Remove a certain part of a string (if exists)?

 

Hi 

I am trying to make the EA look for a certain value in a string and if that value exists in the string then remove it.


I tried doing it using the StringReplace() but i noticed it only returns the number of replacements and didnt actually returned the updated string:

string v5="- .82523";
          string temp2 =  v5;
          temp2= StringReplace(temp2," ","");
          Print(v5,temp2);

in the above code there is a white space between "-" and ".82523" and i  am trying to remove that white space.

so the string is       - .82523     and i am trying to get     -.82523 , which function can be used for this ? 

initially i thought i could do it by using the StringReplace() function , but seems like it only returns the Number of replacements that had happened and not the updated string.


Thanks in Advance

 

Read the documentation on the function StringReplace() - https://docs.mql4.com/strings/stringreplace

string v5="- .82523";
string temp2 =  v5;
int CountReplaced = StringReplace(temp2," ","");
PrintFormat("Count: %d, v5: [%s], temp2: [%s]", CountReplaced, v5, temp2);

Run the above code and see what is printed before you post any comments!

 
Fernando Carreiro:

Read the documentation on the function StringReplace() - https://docs.mql4.com/strings/stringreplace

Run the above code and see what is printed before you post any comments!

Understood , thank you for the help 

Reason: