C#取中间文本
发布时间:2020-01-16 22:03
可参考以下代码:
/// <summary>
/// 取中间文本 + static string GetMiddleStr(string oldStr,string preStr,string nextStr)
/// </summary>
/// <param name="oldStr">原文</param>
/// <param name="preStr">前文</param>
/// <param name="nextStr">后文</param>
/// <returns></returns>
public static string GetMiddleStr(string oldStr, string preStr, string nextStr)
{
string tempStr = oldStr.Substring(oldStr.IndexOf(preStr) + preStr.Length);
tempStr = tempStr.Substring(0, tempStr.IndexOf(nextStr));
return tempStr;
}