যাচাই করতে, আপনাকে প্রোটোকলগুলি পরীক্ষা করতে হবে৷
৷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("The Expression: " + 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("Matching URL...");
showMatch(str, @"^(http|http(s)?://)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)?");
Console.ReadKey();
}
}
} আউটপুট
Matching URL... The Expression: ^(http|http(s)?://)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)? https://example.com