读书人

怎么取地址

发布时间: 2012-02-21 16:26:23 作者: rapoo

如何取地址?
大家好,我想的功能:


在量str中查符合@yahoo.com格式的地址,并其放到a中。

代如何?

[解决办法]

C# code
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:
JScript code
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等形式
这种采集的效果很难说了。

读书人网 >JavaScript

热点推荐