首页 > 其他 > 详细

[转]c#截取指定长度的字符串

时间:2014-03-04 20:20:56      阅读:503      评论:0      收藏:0      [点我收藏+]

/// <summary>
/// 截取指定長度的字符串
/// </summary>
/// <param name="s"></param>
/// <param name="len"></param>
/// <param name="style"></param>
/// <returns></returns>
private string GetStrLenAll(string s, int len, string style)
{
string temp = s;
if (Regex.Replace(temp, "[^\x00-\xff]", "zz", RegexOptions.IgnoreCase).Length <= len)
{
return temp;
}
for (int i = temp.Length; i >= 0; i--)
{
temp = temp.Substring(0, i);
if (Regex.Replace(temp, "[^\x00-\xff]", "zz", RegexOptions.IgnoreCase).Length <= len - style.Length)
{
return temp + style;
}
}
return "";
}

 

来源:http://wenku.baidu.com/link?url=87hx6gFRuPuXqNs-K4s0JxsMWEQlUQ4XlNtEfWDkiFLy1EEExkCJvaYdsJN6EbzJZPf1tQcbeoWq4MMn09JBSwjLAPx3ghTUsmIENSkmZyS###

[转]c#截取指定长度的字符串,布布扣,bubuko.com

[转]c#截取指定长度的字符串

原文:http://www.cnblogs.com/seasons1987/p/3579708.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!