/// <Summary>
/// String delimiter
/// </Summary>
Public const string separatorstring = "#$ @#$ ";
/// <Summary>
/// Obtain the character number. The string is separated by a delimiter. The POS starts with 1.
/// </Summary>
/// <Param name = "str"> string </param>
/// <Param name = "separator"> delimiter </param>
/// <Param name = "POS"> Number </param>
/// <Returns> returns the nth string </returns>
/// <Example> string STR = Split ("rrrrddrew @ tqwewerewddccc", "@", 1); </example>
Public static string split (string STR, string separator, int POS)
{
Int Len = Str. length;
Int COUNT = Str. Length-Str. Replace (separator, ""). length;
Int bitcount = 0;
String returnvalue = "";
String strvalue = "";
String inseparator = "";
If (COUNT = 0)
{
Return STR;
}
Inseparator = Str. substring (Str. Length-separator. length, separator. Length );
If (inseparator! = Separator)
{
STR + = separator;
}
For (INT I = 0; I <count; I ++)
{
Bitcount = Str. indexof (separator, 0 );
Strvalue = Str. substring (0, bitcount );
STR = Str. Replace (strvalue + separator ,"");
If (I = pos-1)
{
Returnvalue = strvalue;
Break;
}
}
Return returnvalue;
}
/// <Summary>
/// Obtain the nth character. It is a string separated by a delimiter. Pos starts with 1 and is separated by the default string.
/// </Summary>
/// <Param name = "str"> string </param>
/// <Param name = "POS"> Number </param>
/// <Returns> returns the nth string </returns>
/// <Example> string STR = Split ("rrrrddrew @ tqwewerewddccc", 1); </example>
Public static string split (string STR, int POS)
{
Int Len = Str. length;
Int COUNT = Str. Length-Str. Replace (separatorstring, ""). length;
Int bitcount = 0;
String returnvalue = "";
String strvalue = "";
String inseparator = "";
If (COUNT = 0)
{
Return STR;
}
Inseparator = Str. substring (Str. Length-separatorstring. length, separatorstring. Length );
If (inseparator! = Separatorstring)
{
STR + = separatorstring;
}
For (INT I = 0; I <count; I ++)
{
Bitcount = Str. indexof (separatorstring, 0 );
Strvalue = Str. substring (0, bitcount );
STR = Str. Replace (strvalue + separatorstring ,"");
If (I = pos-1)
{
Returnvalue = strvalue;
Break;
}
}
Return returnvalue;
}
/// <Summary>
/// Obtain the split string data. The array starts with 0.
/// </Summary>
/// <Param name = "str"> string </param>
/// <Param name = "separator"> delimiter </param>
/// <Returns> returns the split String Array </returns>
/// <Example> string STR = Split ("rrrrddrew @ tqwewerewddccc @", "@") [1]. tostring () </example>
Public static string [] Split (string STR, string separator)
{
Int Len = Str. length;
Int COUNT = 0;
Int bitcount = 0;
String strvalue = "";
String inseparator = "";
Inseparator = Str. substring (Str. Length-separator. length, separator. Length );
If (inseparator! = Separator)
{
STR + = separator;
}
Count = (Str. Length-Str. Replace (separator, ""). Length)/separator. length;
String [] returnvalue = new string [count];
For (INT I = 0; I <count; I ++)
{
Bitcount = Str. indexof (separator, 0 );
Strvalue = Str. substring (0, bitcount );
STR = Str. Replace (strvalue + separator ,"");
// MessageBox. Show (bitcount. tostring () + ";" + strvalue. tostring () + ";" + Str );
Returnvalue [I] = strvalue;
}
Return returnvalue;
}
/// <Summary>
/// Obtain the split string data. The array starts with 0 and is separated by the default string.
/// </Summary>
/// <Param name = "str"> string </param>
/// <Returns> returns the split String Array </returns>
/// <Example> string STR = Split ("rrrrddrew @ tqwewerewddccc @") [1]. tostring () </example>
Public static string [] Split (string Str)
{
Int Len = Str. length;
Int COUNT = 0;
Int bitcount = 0;
String strvalue = "";
String inseparator = "";
Inseparator = Str. substring (Str. Length-separatorstring. length, separatorstring. Length );
If (inseparator! = Separatorstring)
{
STR + = separatorstring;
}
Count = (Str. Length-Str. Replace (separatorstring, ""). Length)/separatorstring. length;
String [] returnvalue = new string [count];
For (INT I = 0; I <count; I ++)
{
Bitcount = Str. indexof (separatorstring, 0 );
Strvalue = Str. substring (0, bitcount );
STR = Str. Replace (strvalue + separatorstring ,"");
// MessageBox. Show (bitcount. tostring () + ";" + strvalue. tostring () + ";" + Str );
Returnvalue [I] = strvalue;
}
Return returnvalue;
}