取文本中间

取两段文本中间的内容

/// <summary>
/// 取中间文本
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <param name="text"></param>
/// <returns></returns>
private ArrayList GetMidText(string left, string right, string text)
{
int leftindex = 0;
int rightindex = 0;
ArrayList re = new ArrayList();
while (text.IndexOf(left, rightindex + right.Length) != -1)
{
leftindex = text.IndexOf(left, rightindex + right.Length);
rightindex = text.IndexOf(right, leftindex + left.Length);
re.Add(text.Substring(leftindex + left.Length, rightindex - leftindex - left.Length));
}
return re;
}
文章作者: NiTian
文章链接: https://www.nitian1207.top/2019/08/02/取文本中间/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 NiTian的小窝
支付宝打赏
微信打赏