如何截取IP地址,最好用正则表达式 如何在字符串中截取IP地址,最好用正则表达式 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一:\d+\.\d+\.\d+\.\d+二:^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$ ^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$ 试试:^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$ ((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?) ((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)Regex r = new Regex(((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)); string message = null; MatchCollection mCollection = r.Matches("搜索的字符串127.0.0.1"); foreach (Match mc in mCollection) { message += mc.Value + "\n"; } int i = mCollection.Count; MessageBox.Show("列表\n" + message + "\n搜索出符合条件的字符串[" + i.ToString() + "]条"); 楼上的不行啊,是不是这个((2[0-4]\d ¦25[0-5] ¦[01]?\d\d?)\.){3}(2[0-4]\d ¦25[0-5] ¦[01]?\d\d?) 不行啊 列表搜索出符合条件的字符串[0]条它有双重意思,要一边搜索IP地址,又要验证IP地址 Regex r = new Regex(((2[0-4]\d ¦25[0-5] ¦[01]?\d\d?)\.){3}(2[0-4]\d ¦25[0-5] ¦[01]?\d\d?)); string message = null; MatchCollection mCollection = r.Matches("搜索的字符串127.0.0.1dsfdf"); foreach (Match mc in mCollection) { message += mc.Value + "\n"; } int i = mCollection.Count; Console.WriteLine("列表\n" + message + "\n搜索出符合条件的字符串[" + i.ToString() + "]条");这代码不行啊列表 搜索出符合条件的字符串[0]条 制作网站与开发web应用程序这两者有什么大不同吗? 发帖的时候如何添加图片 程序集引用问题 web整站下载相关代码 把字符串相反输出 三态树控件下载 大家哪位有关于GDI+做开发的资料。 有谁知道这个基础性的问题吗,请教了!!谢谢 刚学C#做了一个聊天的!!但是不知道为什么关不掉!!请高手帮忙!! 有谁知道如何转换电子邮件中的字符为正常的字符串? 执行完查询语句生成的结果还能进一步执行查询语句吗? dock的怪问题
二:^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0).(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$
^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$
string message = null;
MatchCollection mCollection = r.Matches("搜索的字符串127.0.0.1");
foreach (Match mc in mCollection)
{
message += mc.Value + "\n";
} int i = mCollection.Count;
MessageBox.Show("列表\n" + message + "\n搜索出符合条件的字符串[" + i.ToString() + "]条");
这个((2[0-4]\d ¦25[0-5] ¦[01]?\d\d?)\.){3}(2[0-4]\d ¦25[0-5] ¦[01]?\d\d?)
不行啊
string message = null;
MatchCollection mCollection = r.Matches("搜索的字符串127.0.0.1dsfdf");
foreach (Match mc in mCollection)
{
message += mc.Value + "\n";
}
int i = mCollection.Count;
Console.WriteLine("列表\n" + message + "\n搜索出符合条件的字符串[" + i.ToString() + "]条");
这代码不行啊列表 搜索出符合条件的字符串[0]条