Home > Backend Development > C#.Net Tutorial > C# identifies whether url is a network path

C# identifies whether url is a network path

大家讲道理
Release: 2016-11-10 14:53:01
Original
1696 people have browsed it

#region 识别urlStr是否是网络路径  
      /// <summary>  
      /// 识别urlStr是否是网络路径  
      /// </summary>  
      /// <param name="urlStr"></param>  
      /// <returns></returns>  
      public static bool UrlDiscern(string urlStr)  
      {  
          if (Regex.IsMatch(urlStr, @"((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)?"))  
          {  
              return true;  
          }  
          else 
          {  
              return false;  
          }  
      }  
      #endregion
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template