+ matchedStrList.RemoveAll();
+ res = regDelim.Match(tmpStr, false, &matchedStrList);
+ matches = matchedStrList.GetCount();
+ if (matches > 0)
+ {
+ String delimiter2 = *(dynamic_cast< String* >(matchedStrList.GetAt(0)));
+
+ // If the 2nd delimiter is empty, the token will be one character followed by 1st delimiter.
+ if (delimiter2.IsEmpty())
+ {
+ ret.Clear();
+ ret.Append(*(__pParseStr + length));
+ length += 1;
+ // Though 2nd delimiter is empty, if 3rd non-empty delimiter exists right after the token, length to be moved should be added by 3rd delimiter.
+ matchedStrList.RemoveAll();
+ String tmpStr1(__pParseStr + length);
+ res = regDelim.Match(tmpStr1, false, &matchedStrList);
+ matches = matchedStrList.GetCount();
+ SysTryReturnResult(NID_BASE_UTIL, matches > 0, E_SUCCESS, "It's a last token.");
+
+ String delimiter3 = *(dynamic_cast< String* >(matchedStrList.GetAt(0)));
+ int index3 = 0;
+ tmpStr1.IndexOf(delimiter3, 0, index3);
+ if (!delimiter3.IsEmpty() && index3 == 0)
+ {
+ length += delimiter3.GetLength();
+ }
+ }
+ else
+ {
+ int delimLength2 = delimiter2.GetLength();
+ int index2 = 0;
+ tmpStr.IndexOf(delimiter2, 0, index2);
+ tmpStr.SubString(0, index2, ret); // Extract the string in between first and second delimiter
+ length += index2 + delimLength2;
+ }
+ }
+ }
+ else
+ {
+ inputStr.SubString(0, index1, ret);
+ length = index1 + delimLength1;
+ }
+ }
+ else // 1st delimiter is empty
+ {
+ // Find 2nd delimiter from "__pParseStr + __position + 1"
+ String tmpStr(__pParseStr + __position + 1);
+ if (tmpStr == null) // When InputStr is last token, extract the token.
+ {
+ ret.Clear();
+ ret.Append(__pParseStr + __position);
+ length = ret.GetLength();
+ }
+ else
+ {
+ matchedStrList.RemoveAll();
+ res = regDelim.Match(tmpStr, false, &matchedStrList);
+ matches = matchedStrList.GetCount();
+ if (matches > 0)
+ {
+ String delimiter2 = *(dynamic_cast< String* >(matchedStrList.GetAt(0)));
+ if (delimiter2.IsEmpty()) // If the 2nd delimiter is also empty, the token will be one character followed by 1st delimiter.
+ {
+ ret.Clear();
+ ret.Append(*(__pParseStr + __position));
+ length = 1;
+ }
+ else
+ {
+ int delimLength2 = delimiter2.GetLength();
+ int index2 = 0;
+ inputStr.IndexOf(delimiter2, 0, index2);
+ inputStr.SubString(0, index2, ret);
+ length = index2 + delimLength2;
+ }
+ }
+ }
+ }
+ }
+ else //There are no delimiters