See this example:
//+------------------------------------------------------------------+ //| Split.mq4 | //| Copyright © 2007, MetaQuotes Software Corp. | //| https://www.metaquotes.net/ru/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, MetaQuotes Software Corp." #property link "https://www.metaquotes.net/ru/" //+------------------------------------------------------------------+ //| fill array of strings | //+------------------------------------------------------------------+ void SplitString(string &ArrayRes[],string InputString,string splitter) { string temp,tempArray[100]; int pos,splitLength=StringLen(splitter),InputStrLength=StringLen(InputString),counter; pos=StringFind(InputString,splitter); if (pos!=-1) { if (pos==0) InputString=StringSubstr(InputString,splitLength,InputStrLength-splitLength); while (StringFind(InputString,splitter)!=-1) { pos=StringFind(InputString,splitter); InputStrLength=StringLen(InputString); tempArray[counter]=StringSubstr(InputString,0,pos); InputString=StringSubstr(InputString,pos+splitLength,InputStrLength-splitLength-pos); counter++; } if (StringLen(InputString)!=0) { tempArray[counter]=InputString; counter++; } } ArrayResize(ArrayRes,counter); for (int i=0;i<counter;i++) { ArrayRes[i]=tempArray[i]; Print("i=",i," string=",ArrayRes[i]); } return; } //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- string strInfo="aae|aer3|dzse|faw323"; string strResult[] ; SplitString(strResult,strInfo,"|"); int N=ArraySize(strResult); if (N>0) { for (int i=0;i<N;i++) Print("strResult[",i,"]=",strResult[i]); } //---- return(0); } //+------------------------------------------------------------------+
I have forgotten to inform, that it is a script.
牛,可惜我自己做了个其他的方法实现了
! 仍然严重感谢!
! 仍然严重感谢!
string strInfo="aae|aer3|dzse|faw323";
string strResult[] ;
strResult = strInfo.split('|');
结果为:
strResult[0]==aae;
strResult[1]==aer3;
strResult[2]==dzse;
strResult[3]==faw323;
大哥们帮帮忙,如果有其他的好的函数可以做,帮帖出,谢谢!