.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;
}
{
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;
}
相关文章推荐
- split按照空格,逗号分割tag
- CSV 文件处理成 String[] ,网银下载的文本中使用逗号分割, 使用双引号标记字段. 使用String split 会出现把引号中的逗号识别的情况 例如 " ,,,, " , "aaa"
- "o_neww_ww_123"分割字符串split
- 详解css中"点","井号","逗号","空格","冒号"的用法
- 详解css中"点","井号","逗号","空格","冒号"的用法
- 用"tar" "split" "cat" 三个命令来分割,合并文件夹
- Regex.Split 在分割 "|" 符号时出现问题,应该使用 "[|]" 才可以分组
- 详解css中"点","井号","逗号","空格","冒号"的用法
- String.split方法对"."分割的处理
- 详解css中"点","井号","逗号","空格","冒号"的用法 .
- java中split以"."分割
- JavaScript 使用split 以中英文逗号、空格(一个或多个)分割字符串
- 长数字隔三位用逗号","隔开,保留两位小数,指定长度,不足补空格
- split(""),默认为按位数分割
- 一个逗号引发的"血案"
- Linux文件分割与合并:split & cat命令
- Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
- 【正则表达式】将前后空格用空字符串替代: str.replace(/(^\s*)|(\s*$)/g, "")
- .NET截取指定长度汉字超出部分以"..."代替
- 在字符串中使用特殊字符<>"'&空格