How to Remove a certain part of a string (if exists)?
How to Remove a certain part of a string (if exists)?
Loading saved threads...
Umer · External communityPost link
External question — Stack Overflow Stack Exchange
Author: Umer
Original post: https://stackoverflow.com/questions/67492410
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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
Quote
Report
PaulB · External communityPost link
External answer — Stack Overflow Stack Exchange
Author: PaulB
Original post: https://stackoverflow.com/a/67492524
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
You are using the
StringReplace()
function incorrectly. Try the following code (from your example).
string v5="- .82523";
string temp2 = v5;
StringReplace(temp2," ","");
Print("<",v5,"> <",temp2,">");
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Stack Overflow Stack Exchange Author: Umer Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/questions/67492410 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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
Checking account access…