[C#] 纯文本查看 复制代码 private string GetLeft(string str, int a)
{
string text = str.Substring(0, a);
return text;
}
private string GetRight(string str, int a)
{
string text = str.Substring(str.Length - a, a);
return text;
}
[C#] 纯文本查看 复制代码 public static string Between(string str, string left, string right)
{
int i = str.IndexOf(left) + left.Length;
string temp = str.Substring(i, str.IndexOf(right, i) - i);
return temp;
}
public static List<string> BetweenArr(string str, string left, string right)
{
List<string> list = new List<string>();
int leftIndex = str.IndexOf(left);
int leftlength = left.Length;
int rightIndex = 0;
string temp = "";
while (leftIndex != -1)
{
rightIndex = str.IndexOf(right, leftIndex + leftlength);
if (rightIndex == -1)
{
break;
}
temp = str.Substring(leftIndex + leftlength, rightIndex - leftIndex - leftlength);
list.Add(temp);
leftIndex = str.IndexOf(left, rightIndex + 1);
}
return list;
}
|