C#REGEX邮件 [英] C# REGEX MAIL
本文介绍了C#REGEX邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要做一些正则表达式,但是我对REGEX的经验不足,所以我需要帮助.
我需要使用正则表达式提取电子邮件地址,但要提取收件人"字段和抄送"字段.
I need to make some regex but I don't have many experience with REGEX so I need help.
I need extract email address with regex but extract To field and CC Field.
示例
收件人: to@example.com; to1@example.com 抄送:
To: to@example.com; to1@example.comCc: cc@example.com;cc1@example.com
我需要把它分成两个数组.
一个数组用于 To:字段,另一个数组用于抄送:
电子邮件
I need broke this to two array.
One array for To: fields and other array for Cc:
emails
注意事项
推荐答案
如果该字符串不包含其他任何内容,请检查此示例:
If the string does not contain anything else, then check this example:
string example = "To: to@example.com; to1@example.com Cc: cc@example.com;cc1@example.com";
string[] to;
string[] cc;
to = Regex.Split( Regex.Match( example, @"^To:\s*(.*)\s+Cc:" ).Groups[1].Value, @"\s*;\s*" );
cc = Regex.Split( Regex.Match( example, @"\sCc:\s*(.*)\s*
").Groups[1] .Value, @" \ s *; \ s *");
" ).Groups[1].Value, @"\s*;\s*" );
这篇关于C#REGEX邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文