silvana1303

string manipulator 1

Aug 2nd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.41 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Text;
  5. using System.Linq;
  6. using System.Windows.Markup;
  7. using System.IO;
  8.  
  9. namespace _01._Furniture
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             string input = Console.ReadLine();
  16.  
  17.             string[] command = Console.ReadLine().Split();
  18.  
  19.             while (command[0] != "End")
  20.             {
  21.                 if (command[0] == "Translate")
  22.                 {
  23.                     if (input.Contains(command[1]))
  24.                     {
  25.                         input = input.Replace(command[1], command[2]);
  26.                         Console.WriteLine(input);
  27.                     }
  28.                    
  29.                 }
  30.                 if (command[0] == "Includes")
  31.                 {
  32.                     bool include = input.Contains(command[1]);
  33.  
  34.                     if (include)
  35.                     {
  36.                         Console.WriteLine(include);
  37.                     }
  38.                     else
  39.                     {
  40.                         Console.WriteLine(include);
  41.                     }
  42.                 }
  43.                 if (command[0] == "Start")
  44.                 {
  45.                     bool start = input.StartsWith(command[1]);
  46.  
  47.                     if (start)
  48.                     {
  49.                         Console.WriteLine(start);
  50.                     }
  51.                     else
  52.                     {
  53.                         Console.WriteLine(start);
  54.                     }
  55.                 }
  56.                 if (command[0] == "Lowercase")
  57.                 {
  58.                     input = input.ToLower();
  59.                     Console.WriteLine(input);
  60.                 }
  61.                 if (command[0] == "FindIndex")
  62.                 {
  63.                     if (input.Contains(command[1]))
  64.                     {
  65.                         int index = input.LastIndexOf(command[1]);
  66.                         Console.WriteLine(index);
  67.                     }
  68.                 }
  69.                 if (command[0] == "Remove")
  70.                 {
  71.                     int index = int.Parse(command[1]);
  72.                     int count = int.Parse(command[2]);
  73.  
  74.                     input = input.Remove(index, count);
  75.                     Console.WriteLine(input);
  76.                 }
  77.  
  78.                 command = Console.ReadLine().Split();
  79.             }
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment