您的位置:首页 > 其它

.net split按照空格,逗号,双引号,"、"分割tag

2007-10-26 13:55 645 查看
public IList<string> Split(string postTag)
{
Regex re = new Regex("/"[//s//S]*?/"");
MatchCollection mas = re.Matches(postTag);
List<string> list = new List<string>();
string TemPost = re.Replace(postTag, ",^#^,");

string[] splitstr ={ " ", ",", "、", "," };
string[] temarray = TemPost.Split(splitstr, StringSplitOptions.RemoveEmptyEntries);
int j = 0;
for (int i = 0; i < temarray.Length; i++)
{
if (!string.IsNullOrEmpty(temarray[i]))
{
if (temarray[i] == "^#^")
{
temarray[i] = mas[j].Value;
j++;
}
list.Add(temarray[i]);
}
}

return list;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐