This works similar to python's string slice, in concept not notation.
#include <Strings\String.mqh> class MyString : public CString { public: string slice(int start, int end) { if(start < 0) start = this.Len() + start; if(end < 0) end = this.Len()+ end; else if(end <= start) end = start; return this.Mid(start, end - start); } MyString *operator = (string in) { this.m_string = in; return &this; } }; void OnStart() { MyString str = "one"; Print(str.slice(0, -1)); // on Print(str.slice(0, 2)); // on str = "MrLuck07"; Print(str.slice(2,-2)); // Luck Print(str.slice(2, 0)); // Luck07 Print(str.slice(0, 2)); // Mr Print(str.slice(-2, 0)); // 07 Print((str="MidSliceMid").slice(3,-3)); // Slice }
Perhaps you should read the manual.
Extracts a substring from a text string starting from the specified position.
String Functions / StringSubstr - Reference on algorithmic/automated trading language for MetaTrader 5
String Functions / StringSubstr - Reference on algorithmic/automated trading language for MetaTrader 5
whroeder1:
Perhaps you should read the manual.
Perhaps you should read the manual.
I gave him the answer above...
thanks a lot for answer
Mrluck07:
thanks a lot for answer
thanks a lot for answer
You're welcome, now don't ever let me catch you saying OOP is useless again! ;)
For the sake of anyone still looking for an answer:
MQL5 use https://www.mql5.com/en/docs/strings/stringreplace

Documentation on MQL5: String Functions / StringReplace
- www.mql5.com
StringReplace - String Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi, please someone can help me to remove letters from words in a string ?
thanks for any help