2
* Created by SharpDevelop.
3
* User: Peter Forstmeier
7
* To change this template use Tools | Options | Coding | Edit Standard Headers.
11
namespace ICSharpCode.Reports.Core.Globals
13
public class StringHelpers
16
/// Left of the first occurance of c
18
/// <param name="src"></param>
19
/// <param name="c"></param>
20
/// <returns></returns>
21
public static string LeftOf(string src, char c)
23
int idx=src.IndexOf(c);
29
return src.Substring(0, idx);
33
/// Left of the n'th occurance of c
35
/// <param name="src"></param>
36
/// <param name="c"></param>
37
/// <param name="n"></param>
38
/// <returns></returns>
39
public static string LeftOf(string src, char c, int n)
44
idx=src.IndexOf(c, idx+1);
51
return src.Substring(0, idx);
55
/// Right of the first occurance of c
57
/// <param name="src"></param>
58
/// <param name="c"></param>
59
/// <returns></returns>
60
public static string RightOf(string src, char c)
62
int idx=src.IndexOf(c);
68
return src.Substring(idx+1);
72
/// Right of the n'th occurance of c
74
/// <param name="src"></param>
75
/// <param name="c"></param>
76
/// <returns></returns>
77
public static string RightOf(string src, char c, int n)
82
idx=src.IndexOf(c, idx+1);
90
return src.Substring(idx+1);
93
public static string LeftOfRightmostOf(string src, char c)
95
int idx=src.LastIndexOf(c);
100
return src.Substring(0, idx);
103
public static string RightOfRightmostOf(string src, char c)
105
int idx=src.LastIndexOf(c);
110
return src.Substring(idx+1);
113
public static string Between(string src, char start, char end)
115
string res=String.Empty;
116
int idxStart=src.IndexOf(start);
120
int idxEnd=src.IndexOf(end, idxStart);
123
res=src.Substring(idxStart, idxEnd-idxStart);
129
public static int Count(string src, char find)
132
foreach(char s in src)