Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- class MainClass
- {
- public static void Main (string[] args)
- {
- string chislo = @"([1-9]\d*|[0])";
- string znach = @"[a-z0-9]";
- string correct_var = $@"([a-z]{znach}*|{chislo})";
- string in_mas = $@"(\s*{correct_var}\s*[-+*/])";
- string arifmetic_in_mas = $@"({in_mas}*\s*{correct_var}\s*)";
- string massiv = $@"[a-z]{znach}*(\[({correct_var}|{arifmetic_in_mas})\])";
- string fun = $@"[a-z]{znach}*(\(({correct_var}|{arifmetic_in_mas})\))";
- string arifmetic_var = $"({correct_var}|{massiv}|{fun})";
- string pattern_arifmetic = $@"(\s*{arifmetic_var}\s*[-+*/])";
- string long_pattern_arifmetic = $@"(({pattern_arifmetic}*)\s*{arifmetic_var})";
- string pattern = $@"([a-z]{znach}*|{massiv}|{fun})\s*=\s*({long_pattern_arifmetic}|{massiv}|{fun}|{chislo})\s*;";
- string str;
- while((str = Console.ReadLine())!= null)
- foreach (Match match in Regex.Matches(str, pattern))
- Console.WriteLine(match.Value);
- }
- }
Add Comment
Please, Sign In to add comment