[email protected];范幼敏,吴国民,王翔;[email protected];;;[email protected];变成:[email protected];[email protected];[email protected];
就是去掉多余分号,以及加逗号的人名.
就是去掉多余分号,以及加逗号的人名.
解决方案 »
- 求助,Dev-GridControl问题。
- 我是学c#的!准备做一个简单的人脸识别的 windows phone 手机应用 能推荐看些什么资料 或书籍 !
- 求大侠 提供一个string驻留机制的实现
- 没盘怎么安装IIS的frontpage扩展?
- 三层开发中, 怎样实现多表的操作?
- 寻找兼职的C#程序员!急切!
- 求计算两个时间差(在法定工作时间内)
- 关于限制活动范围的实现
- C# 怎样实现Directsound混音啊?
- 各位!哪里有用C#写ASP.NET的EBook下载,多谢!多谢!
- windows service中实现tcp监听,但不知道为什么就是不可以!!着急等待
- Visual Studion换版本需要卸载再安装吗
void Main()
{
string str="[email protected];范幼敏,吴国民,王翔;[email protected];;;[email protected];";
str=Regex.Replace(str,@"(?:[\u4e00-\u9fa5]+[,;]|;{2,})",m=>Regex.IsMatch(m.Value,";{2,}")?";":"");
Console.WriteLine(str);//[email protected];[email protected];[email protected];}
{
//string input = "[email protected];范幼敏,吴国民,王翔;[email protected];;;[email protected];";
string output = string.Empty; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})");
System.Text.RegularExpressions.MatchCollection mc = regex.Matches(input); foreach (System.Text.RegularExpressions.Match m in mc)
{
output += m.Value + ";";
} return output;
}
string[] mc= System.Text.RegularExpressions.Regex.Split(MailTo, ";");
MailTo="";
for (int i = 0; i < mc.Length; i++)
{
if(mc[i].ToString().Length>1&&mc[i].ToString().IndexOf(",")==-1){MailTo+=mc[i].ToString();MailTo+=";";}
}
你这个不行吧?
你这个只能适合你提供的这个字符串,是个特例,不能包括所有的情况。
比如 [email protected];范幼敏,吴国民,王翔;[email protected];;;[email protected];123; 最后这个123也是符合你的条件的。
判断这些东西,不光要测试符合,还要测试不符合。