トップ  >  MQL4リファレンス  >  文字列関数  >  StringSplit
スポンサーリンク
検索

↑の検索エンジンが表示されない人は、
↓の古い検索エンジンを使用して下さい。
カスタム検索
MQL4リファレンスツリー
StringSplit


StringSplit


文字列を指定した文字で分離します

関数書式:
int  StringSplit(
   const string   string_value,       // 分離する文字列
   const ushort   separator,          // セパレーター
   string         & result[]          // 分離された文字列を格納する文字列配列
   );



■引数
引数名 初期値 I/O 詳細
string_value - In 分離する文字列
(この文字列自身は分離されません)
separator - In 区切り用の文字コード。
指定した文字コードで文字列を分離します。
文字列から文字コードを取得するにはStringGetCharacter()関数を使用します。
result[] - Out 分離された文字列を格納する文字列配列


■戻り値
result[]配列の配列数を返します。
セパレーターが見つからなかった場合は、string_valueの文字列だけがresult[]配列に格納されます。

string_valueが空またはNULLの場合は0を返します。
エラーの場合は-1を返します。
エラーコードを取得するにはGetLastError()関数を使用します。


■備考
無し


サンプルソース:
#property strict // strictは絶対に削除しない事

void OnInit() {
    string tempstr = "123_456_789";
    string sep_str[];
    int    sep_num;

    sep_num = StringSplit(tempstr , '_' , sep_str);

    Print("ソース文字列:",tempstr);

    for ( int icount = 0; icount < sep_num ; icount++ ) {
        printf("sep_str[%d]:%s",icount,sep_str[icount]);
    }    
}


結果:
ソース文字列:123_456_789
sep_str[0]:123
sep_str[1]:456
sep_str[2]:789





スポンサーリンク
スポンサーリンク


Copyright ©2015 MT4でEA自作しちゃお~ All Rights Reserved.


Top

inserted by FC2 system