C# 取中间文本最实用的代码
1 /// <summary> 2 /// 取中间文本 3 /// </summary> 4 /// <param name="str">全文本</param> 5 /// <param name="str1">前文本</param> 6 /// <param name="str2">后文本</param> 7 /// <returns></returns> 8 public static string 取中间文本(string str, string str1, string str2) 9 { 10 int i1 = str.IndexOf(str1); 11 int i2 = -1; 12 string strok = ""; 13 if (i1 != -1) 14 { 15 i2 = str.IndexOf(str2, i1); 16 } 17 if (i2 != -1) 18 { 19 strok = str.Substring(i1 + 1, i2 - i1 - 1); 20 } 21 return strok; 22 }