Advertisement
YavorGrancharov

Capitalize_Words(text_process)

Aug 2nd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Capitalize_Words
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string input = Console.ReadLine();
  11.  
  12.             while (input != "end")
  13.             {
  14.                 string[] tokens = input
  15.                     .Split(new[]
  16.                     { ' ', '!', '\\', '@', '#', '$', '%', '^', '&', '*',
  17.                         '(', ')', '|', '/', '.', ':', '"', ',', '+', '-',
  18.                         '=', ';', '<', '>', '[', ']', '{', '}', '_', '~',
  19.                         '`', '§', '°', '²', '³', '?'},
  20.                     StringSplitOptions.RemoveEmptyEntries);
  21.  
  22.                 string parts = string.Empty;
  23.                 for (int i = 0; i < tokens.Length; i++)
  24.                 {
  25.                     parts += tokens[i].ToLower() + ", ";
  26.                 }
  27.  
  28.                 string result = System.Globalization
  29.                     .CultureInfo
  30.                     .InvariantCulture
  31.                     .TextInfo
  32.                     .ToTitleCase(parts);
  33.  
  34.                 Console.WriteLine(result.TrimEnd(',', ' '));
  35.  
  36.                 input = Console.ReadLine();
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement