try
{
//查找的字符串
string weatherurlreturn = result;
//起始字符
string star = "GeoIP: ";
//结束字符
string end = ",";
string msg = string.Empty;
int s = weatherurlreturn.IndexOf(star);
if (s != null)
{
int e = weatherurlreturn.IndexOf(end, s);
if (s != null && e != null)
{
msg = weatherurlreturn.Substring(s, e - s);
msg = msg.Replace(star, "");
msg = msg.Replace(end, "");
}
}
if (!string.IsNullOrEmpty(msg))
{
return msg;
}
return string.Empty;
}
catch (Exception ex)
{
return string.Empty;
}
字符串截取
最新推荐文章于 2023-02-02 09:47:02 发布