StringFind

문자열에서 부분 문자열을 검색합니다.

int  StringFind(
   string  string_value,        // 검색할 문자열
   string  match_substring,     // 검색된 것
   int     start_pos=0          // 어떤 위치에서부터 검색을 시작하는지.
   );

매개 변수

string_value

[in]  검색을 할 문자열.

match_substring

[in]  검색된 하위 문자열.

start_pos=0

[in]  검색을 시작할 문자열의 위치.

반환값

검색된 하위 문자열이 시작되는 문자열의 위치 번호 또는 하위 문자열을 찾을 수 없는 경우 -1을 반환합니다.

예:

#define   RESERVE    100
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- 심볼 기본 통화와 수익 통화를 가져옵니다.
   string symbol_currency_base  =SymbolInfoString(Symbol(), SYMBOL_CURRENCY_BASE);
   string symbol_currency_profit=SymbolInfoString(Symbol(), SYMBOL_CURRENCY_PROFIT);
   PrintFormat("Symbol Currency Base: %s\nSymbol Currency Profit: %s"symbol_currency_basesymbol_currency_profit);
   
//--- 서버에서 사용 가능한 모든 심볼의 루프
   int total=SymbolsTotal(false), pos=-1;
   for(int i=0i<totali++)
     {
//--- 다음 심볼의 이름을 얻습니다.
      string name=SymbolName(ifalse);
      
//--- 기본 통화 이름이 포함된 심볼 이름에서 하위 문자열을 찾고
//--- 하위 문자열이 발견되면 심볼 이름, 해당 색인을 통화 목록에 표시하고 검색된 통화 이름을 로그에 표시합니다.
      pos = StringFind(namesymbol_currency_base);
      if(pos >= 0)
         PrintFormat("The '%s' symbol at index %u in the list contains the '%s' currency. Substring position in the symbol name: %d"nameisymbol_currency_basepos);
         
//--- 인용된 통화명이 포함된 심볼명에서 하위 문자열을 찾고
//--- 하위 문자열이 발견되면 심볼 이름, 해당 색인을 통화 목록에 표시하고 검색된 통화 이름을 로그에 표시합니다.
      pos = StringFind(namesymbol_currency_profit);
      if(pos >= 0)
         PrintFormat("The '%s' symbol at index %u in the list contains the '%s' currency. Substring position in the symbol name: %d"nameisymbol_currency_profitpos);
     }
      
  /*
  결과
   StringFind (EURUSD,D1)   Symbol Currency BaseEUR
   StringFind (EURUSD,D1)   Symbol Currency ProfitUSD
   The 'EURUSDsymbol at index 0 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURUSDsymbol at index 0 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'GBPUSDsymbol at index 1 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'USDCHFsymbol at index 2 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDJPYsymbol at index 3 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDCNHsymbol at index 4 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDRUBsymbol at index 5 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'AUDUSDsymbol at index 6 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'NZDUSDsymbol at index 7 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'USDCADsymbol at index 8 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDSEKsymbol at index 9 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDHKDsymbol at index 10 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDSGDsymbol at index 11 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDNOKsymbol at index 12 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDDKKsymbol at index 13 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDTRYsymbol at index 14 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDZARsymbol at index 15 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDCZKsymbol at index 16 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDHUFsymbol at index 17 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDPLNsymbol at index 18 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDRURsymbol at index 19 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURAUDsymbol at index 27 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCADsymbol at index 28 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCHFsymbol at index 29 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCZKsymbol at index 30 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURDKKsymbol at index 31 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURGBPsymbol at index 32 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURHKDsymbol at index 33 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURHUFsymbol at index 34 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURJPYsymbol at index 35 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURNOKsymbol at index 36 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURNZDsymbol at index 37 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURPLNsymbol at index 38 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURRURsymbol at index 39 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURRUBsymbol at index 40 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURSEKsymbol at index 41 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURTRYsymbol at index 42 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURZARsymbol at index 43 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'XAUUSDsymbol at index 47 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'XAUEURsymbol at index 48 in the list contains the 'EURcurrencySubstring position in the symbol name3
   The 'XAGUSDsymbol at index 50 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'XAGEURsymbol at index 51 in the list contains the 'EURcurrencySubstring position in the symbol name3
   The 'USDCREsymbol at index 53 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'XPDUSDsymbol at index 65 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'XPTUSDsymbol at index 66 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'USDGELsymbol at index 67 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDMXNsymbol at index 68 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURMXNsymbol at index 69 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'USDCOPsymbol at index 75 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDARSsymbol at index 76 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDCLPsymbol at index 77 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURSGDsymbol at index 89 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'USDILSsymbol at index 95 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDTHBsymbol at index 122 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDRMBsymbol at index 123 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURILSsymbol at index 126 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCNHsymbol at index 137 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'USDBRLsymbol at index 139 in the list contains the 'USDcurrencySubstring position in the symbol name0
  */
  }

참고 항목

StringSubstr, StringGetCharacter, StringLen, StringLen