Advertisement
Cinder1986

Lab18-1

Mar 26th, 2023
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System.Text.RegularExpressions;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static bool test(string line)
  8.         {
  9.             Regex lineExtension = new Regex(@"\.(txt|(html|php))$");
  10.             return lineExtension.IsMatch(line);
  11.         }
  12.         static void Main(string[] args)
  13.         {
  14.             Console.Write("Enter a line: ");
  15.             Console.Write(test(Console.ReadLine()) ? "The line contains the extensions" : "The line does not contain the extensions");
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement