Advertisement
allia

vv

Feb 15th, 2021
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Text;  
  3. using System.Text.RegularExpressions;
  4.  
  5. class MainClass
  6. {
  7.    public static void Main (string[] args)
  8.   {
  9.     string chislo = @"([1-9]\d*|[0])";
  10.     string znach = @"[a-z0-9]";
  11.    
  12.     string correct_var = $@"(([a-z]{znach}*)|{chislo})";
  13.     string arifmetic_in_mas = $@"(\s*{correct_var}\s*[-+/*])";
  14.     string long_pattern_in_mas = $@"(({arifmetic_in_mas}*)\s*{correct_var}\s*)";
  15.  
  16.     //string massiv = $@"[a-z]{znach}*(\[({correct_var}|{long_pattern_in_mas})\])?";
  17.     string fun = $@"[a-z]{znach}*(\(({correct_var}|{long_pattern_in_mas})\))";
  18.  
  19.     //string arifmetic = $"({correct_var}|{massiv}|{fun})";
  20.     //string pattern_arifmetic = $@"(\s*{arifmetic}\s*[-+*/])";
  21.     //string long_pattern_arifmetic = $@"(({pattern_arifmetic}*)\s*{arifmetic})";
  22.    
  23.     //string pattern = $@"[a-z]{znach}*\s*=\s*({long_pattern_arifmetic}|{massiv}|{fun}|{chislo})\s*;";
  24.     string str;
  25.  
  26.     while((str = Console.ReadLine())!= null)
  27.       foreach (Match match in Regex.Matches(str, correct_var))
  28.          Console.WriteLine(match.Value);
  29.   }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement