【问题标题】:How to detect string end position in mql4?如何检测 mql4 中的字符串结束位置?
【发布时间】:2018-08-02 23:07:07
【问题描述】:

我试图弄清楚如何找到字符串的结尾。我能够得到我想要的字符串中的第一个数字(6),但我不知道如何计算到字符串的末尾</td>。我的想法是如果我能弄清楚它有多远从 6 到右括号,然后我可以子串得到数字 6586.97。这是正确的想法吗?

示例字符串<td>6586.97 Lots</td>

【问题讨论】:

    标签: string substring mql4


    【解决方案1】:

    丹尼尔,谢谢您的回复。这就是我喜欢编码的原因。有多种方法可以完成工作。我昨晚深夜想出了一个解决方案,并将在此处发布。

     Count=0;
         for (int i =0 ; i<20; i++){
         VOL1=StringSubstr(data,string_pos+112+i+string_length,1);
            if(VOL1!="/")Count++;
               else{Answer=StringSubstr(data,string_pos+112+string_length,Count-6);}}
         return(Answer);
    

    我所做的是,从 6 开始,我一直向右移动,直到找到正斜杠。然后 StringSubstr 回来。

    【讨论】:

      【解决方案2】:

      使用StringFind() 检测以“>”开头的消息的开头和消息的结尾(空格键),不要忘记在开始后开始寻找结尾。 StringSubstr()是剪掉你需要的字符串

      string getStringFromTag(const string example){
          int starts = StringFind(example,">");
          if(starts>0){
             int ends = StringFind(example," ",starts+1);
             if(ends>0){
                string result=StringSubstr(starts+1,ends-starts-1);
                   return result;
             }
          }
          return NULL;}
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-23
      • 2019-09-09
      • 2021-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多