Advertisement
Guest User

Example_6_Regex

a guest
Feb 9th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace Regular_Expression
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] sites = {
  11.                 "http://www.google.com",
  12.                 "https://www.google.com",
  13.                 "http://google.com",
  14.                 "www.google.com",
  15.                 "google.com"
  16.             };
  17.  
  18.             for (int i = 0; i < sites.Length; i++)
  19.             {
  20.                 string pattern = @"(http)?(s)?(://)?(w{3}\.)?\w+\.\w+";
  21.                 bool ismatch = Regex.IsMatch(sites[i], pattern);
  22.                 Console.WriteLine(ismatch);
  23.             }
  24.             Console.ReadLine();
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement