मान्य करने के लिए, आपको प्रोटोकॉल की जांच करनी होगी।
http https
इसके साथ, आपको .com, .in, .org, आदि की जांच करनी होगी।
इसके लिए, निम्नलिखित नियमित अभिव्यक्ति का उपयोग करें:
(http|http(s)?://)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)?
निम्नलिखित कोड है:
उदाहरण
using System; using System.Text.RegularExpressions; namespace RegExApplication { class Program { private static void showMatch(string text, string expr) { Console.WriteLine("अभिव्यक्ति: " + expr); MatchCollection mc = Regex.Matches(text, expr); foreach (Match m in mc) { Console.WriteLine(m); } } static void Main(string[] args) { string str = "https://example.com"; Console.WriteLine("URL मिलान..."); showMatch(str, @"^(http|http(s)?://)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)?"); Console.ReadKey(); } } }आउटपुट
URL मिलान... अभिव्यक्ति: ^(http|http(s)?://)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)? https://example.com