Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace _02.CountSubstringOccurrences
  9. {
  10.     class CountSubstringOccurrences
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string text = Console.ReadLine().ToUpper();
  15.             string word = Console.ReadLine().ToUpper();
  16.             string pattern = $@"{word}";
  17.  
  18.             int numberAppears = Regex.Matches(Regex.Escape(text), pattern).Count;
  19.             Console.WriteLine(numberAppears);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement