根据前后的子串求中间串的函数
using System.Text.RegularExpressions;
/// <summary>
/// 给出一个字符串,前面的子串和后面的子串,返回中间的子串(删除空格)
/// </summary>
/// <param name="s"></param>
/// <param name="s1">如果前面要顶头,s1=""</param>
/// <param name="s2">如果后面要是结尾,s2="$"</param>
/// <returns></returns>
private string GetMod(string s,string s1,string s2)
{
Regex re=new Regex(s1 + @".*" + s2);
Match ma=re.Match(s);
if( ma.Success)
return ma.Value.Substring(s1.Length,ma.Length-s1.Length -s2.Length).Trim();
else
MessageBox.Show("未在 " + s +" 中发现适合的字符串!");
return "";
}
/// <summary>
/// 给出一个字符串,前面的子串和后面的子串,返回中间的子串(删除空格)
/// </summary>
/// <param name="s"></param>
/// <param name="s1">如果前面要顶头,s1=""</param>
/// <param name="s2">如果后面要是结尾,s2="$"</param>
/// <returns></returns>
private string GetMod(string s,string s1,string s2)
{
Regex re=new Regex(s1 + @".*" + s2);
Match ma=re.Match(s);
if( ma.Success)
return ma.Value.Substring(s1.Length,ma.Length-s1.Length -s2.Length).Trim();
else
MessageBox.Show("未在 " + s +" 中发现适合的字符串!");
return "";
}