IP地址正则式(转)

private bool FoundMatch(string txt)
{
    try
    {
        return Regex.IsMatch(txt, @"^(\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])$");
    }
    catch (ArgumentException ex)
    {
        //   Syntax   error   in   the   regular   expression 
        return false;
    }
}
posted @ 2009-03-17 16:00  木瓜脑袋  阅读(432)  评论(0编辑  收藏  举报