Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Text.RegularExpressions;
- class SentencePrint
- {
- static void Main(string[] args)
- {
- string text = "\tНалей ми бира!" +
- "Изстина бирата заради тези регулярни изрази." +
- "Ще сложа две-три в камерата.\n" +
- "\t Отивам до магазина за още бира.";
- string splitPattern = @"[.|!|?|\t|\n]";
- string[] sents = Regex.Split(text, splitPattern);
- foreach (var sent in sents)
- {
- if (sent == "")
- {
- continue;
- }
- string pattern = (@"\b(бира)\b");
- Match match = Regex.Match(sent, pattern);
- bool sign = false;
- while (match.Success)
- {
- sign = true;
- //Console.WriteLine("Низ: \"{0}\" - начало {1}, дължина {2}", match, match.Index, match.Length);
- match = match.NextMatch();
- }
- if (sign == true)
- {
- Console.WriteLine(sent.Trim());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement