如何獲取電郵地址?
大家好,我想實現這樣的功能:
在變量str中查詢符合@yahoo.com格式的電郵地址,并將其放到數組a中。
請問代碼如何寫?
[解决办法]
using System.Text.RegularExpressions;//字符串string str = "abc@yahoo.com alsdjfsaldjfa as a@yahoo.com asdf";string pattern = @"\S+@yahoo.com";Regex reg = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline);MatchCollection mc = reg.Matches(str);string[] result = new string[mc.Count];for (int i = 0; i < mc.Count; i++){ result[i] = mc[i].ToString();}//----测试for (int i = 0; i < result.Length; i++){ Response.Write(result[i] + "<br />");}
[解决办法]
用javascript:
var str = "abc@yahoo.com alsdjfsaldjfa as a@yahoo.com asdf";var reg = /\S+@yahoo.com/gi;var result = str.match(reg); //result为数组
[解决办法]
现在一般人都注意了,邮箱都改成
abc#yahoo.com或
abc_yahoo.com等形式
这种采集的效果很难说了。