c#截取字符串归纳总结
2021-01-07 12:28
标签:reac split OLE color ons 形式 trim class fir string str ="11- 3 [1,2,3,4] Q ERTY$ %^ 23"; c#截取字符串归纳总结 标签:reac split OLE color ons 形式 trim class fir 原文地址:https://www.cnblogs.com/colapopo/p/13152473.html
var first = str.Substring(0, 1);
var last = str.Substring(str.Length - i,1);
string left = "[";
string right = "]";
int IndexofLeft = stra.IndexOf(left);
int IndexofRight = stra.IndexOf(right);
string arr = stra.Substring(IndexofLeft + 1, IndexofRight - IndexofLeft -1);
string[] Array = arr.Split(string[]{‘,‘});
foreach(string a in Array)
{
Console.WriteLine(a);
}
int qBefore = str.IndexOf("Q");
var before = str.Substring(0, qBefore- 1).Trim();
int qAfter = str.LastIndexOf("Q");
var after= str.Substring(qAfter + 1).Trim();
上一篇:API自学总结