Advertisement
silvana1303

string manipulator 2

Aug 2nd, 2020 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace _02._Boss_Rush
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string input = Console.ReadLine();
  13.  
  14.             string[] command = Console.ReadLine().Split();
  15.  
  16.             while (command[0] != "Done")
  17.             {
  18.                 if (command[0] == "Change")
  19.                 {
  20.                     input = input.Replace(command[1], command[2]);
  21.                     Console.WriteLine(input);
  22.                 }
  23.                 if (command[0] == "Includes")
  24.                 {
  25.                     bool includes = input.Contains(command[1]);
  26.                     Console.WriteLine(includes);
  27.                 }
  28.                 if (command[0] == "End")
  29.                 {
  30.                     bool end = input.EndsWith(command[1]);
  31.                     Console.WriteLine(end);
  32.                 }
  33.                 if (command[0] == "Uppercase")
  34.                 {
  35.                     input = input.ToUpper();
  36.                     Console.WriteLine(input);
  37.                 }
  38.                 if (command[0] == "FindIndex")
  39.                 {
  40.                     int index = input.IndexOf(command[1]);
  41.                     Console.WriteLine(index);
  42.                 }
  43.                 if (command[0] == "Cut")
  44.                 {
  45.                     int index = int.Parse(command[1]);
  46.                     int lenght = int.Parse(command[2]);
  47.  
  48.                     input = input.Substring(index, lenght);
  49.                     Console.WriteLine(input);
  50.                 }
  51.  
  52.                 command = Console.ReadLine().Split();
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement