Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Collections.Generic;
- using System.Linq;
- namespace ExtractPalindromes
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input=Console.ReadLine();
- var list = new List<string>();
- Regex regexForWord = new Regex(@"[a-zA-Z]+");
- MatchCollection words = regexForWord.Matches(input);
- foreach (Match match in words)
- {
- string currentWord = match.Value;
- char [] reverse =currentWord.Reverse().ToArray(); //char Array
- string reverseCurrentWord = (string.Join("", reverse)).ToString();
- if (currentWord == reverseCurrentWord)
- {
- list.Add(currentWord);
- }
- }
- Console.WriteLine(string.Join(", ",list));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement