Hello,
You can do it using a regular expression as shown below.
using System;
using System.Text.RegularExpressions;
class SplitStringTester {
public string[] RegxSplit(string pattern, string input) {
int i = 0;
string[] arrRet = null;
Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection matches = rgx.Matches(input);
if (matches.Count > 0)
{
arrRet = new string[matches.Count];
foreach(Match m in matches) {
arrRet[i] = m.Value;
i++;
}
}
return arrRet;
}
public static void Main() {
SplitStringTester tst = new SplitStringTester();
string[] arrRet = tst.RegxSplit(@"(.{5})?", @"q2px1tfi9jNvrX07uxH78DUCzuXZKlwZjtN3iruaMi0=");
if (arrRet != null) {
Console.WriteLine("{0} ({1} matches):", @"q2px1tfi9jNvrX07uxH78DUCzuXZKlwZjtN3iruaMi0=", arrRet.Length);
foreach (string sTok in arrRet)
Console.WriteLine(sTok);
}
Console.ReadKey();
}
}
Another way could be found
here[
^].
Regards,