50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
namespace ln.rtp
|
|
{
|
|
public static class StringExtensions
|
|
{
|
|
public static string ReadToken(this string line, out string rest)
|
|
{
|
|
int n = 0;
|
|
while (!char.IsWhiteSpace(line[n]))
|
|
n++;
|
|
|
|
int m = n;
|
|
while (char.IsWhiteSpace(line[m]))
|
|
m++;
|
|
|
|
string token = line.Substring(0, n);
|
|
rest = line.Substring(m);
|
|
return token;
|
|
}
|
|
|
|
public static string ReadToken(this string line, char delimiter)
|
|
{
|
|
int n = 0;
|
|
while (delimiter != line[n])
|
|
n++;
|
|
|
|
int m = n;
|
|
while (delimiter == line[m])
|
|
m++;
|
|
|
|
string token = line.Substring(0, n);
|
|
return token;
|
|
}
|
|
|
|
public static string ReadToken(this string line, char delimiter, out string rest)
|
|
{
|
|
int n = 0;
|
|
while (delimiter != line[n])
|
|
n++;
|
|
|
|
int m = n;
|
|
while (delimiter == line[m])
|
|
m++;
|
|
|
|
string token = line.Substring(0, n);
|
|
rest = line.Substring(m);
|
|
return token;
|
|
}
|
|
|
|
}
|
|
} |