字符串 :执行日期12.1-3.28执行
结果得到中间的日期:12.1-3.28
remark="执行日期12.1-3.28执行";
data="执行日期";
string value = "";
if (!string.IsNullOrEmpty(remark))
{
if (remark.Contains(data))
{
int startIndex = remark.IndexOf(data);
if (remark.EndsWith("执行"))
{
int endIndex = remark.LastIndexOf("执行");
int length = endIndex - startIndex - data.Length;
value = remark.Substring(startIndex + data.Length, length);
}
else
{
value = remark.Substring(startIndex + data.Length);
}
}
}
return value;