/
StringHelperClass.cs
35 lines (32 loc) · 1.19 KB
/
StringHelperClass.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//----------------------------------------------------------------------------------------
// Copyright © 2009 - 2010 Tangible Software Solutions Inc.
// This class can be used by anyone provided that the copyright notice remains intact.
//
// This class is used to replace most calls to the Java String.split method.
//----------------------------------------------------------------------------------------
internal static class StringHelperClass
{
//------------------------------------------------------------------------------------
// This method is used to replace most calls to the Java String.split method.
//------------------------------------------------------------------------------------
internal static string[] StringSplit(string source, string regexDelimiter, bool trimTrailingEmptyStrings)
{
string[] splitArray = System.Text.RegularExpressions.Regex.Split(source, regexDelimiter);
if (trimTrailingEmptyStrings)
{
if (splitArray.Length > 1)
{
for (int i = splitArray.Length; i > 0; i--)
{
if (splitArray[i - 1].Length > 0)
{
if (i < splitArray.Length)
System.Array.Resize(ref splitArray, i);
break;
}
}
}
}
return splitArray;
}
}