From eaed3f058fd5b04774fbf81352bceeab2d55403e Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 22 Nov 2021 01:37:06 +0200 Subject: [PATCH] feat: handle edge case when last and first have different casing --- Lab4.FirstEqualLast/TaskUtils.cs | 5 ++--- Lab4.RemoveComments/Program.cs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lab4.FirstEqualLast/TaskUtils.cs b/Lab4.FirstEqualLast/TaskUtils.cs index af0fe1d..87945c6 100644 --- a/Lab4.FirstEqualLast/TaskUtils.cs +++ b/Lab4.FirstEqualLast/TaskUtils.cs @@ -27,7 +27,7 @@ namespace Lab4.FirstEqualLast @param punctuation – punctuation marks to separate words */ private static int FirstEqualLast (string line, string punctuation) { - string[] parts = Regex.Split(line, punctuation); + string[] parts = Regex.Split(line.ToLower(), punctuation); int equal = 0; foreach (string word in parts) if(word.Length > 0) // empty words at the end of line @@ -56,8 +56,7 @@ namespace Lab4.FirstEqualLast @param punctuation – punctuation marks to separate words */ private static int FirstEqualLast (string line, char[] punctuation) { - string[] parts = line.Split(punctuation, - StringSplitOptions.RemoveEmptyEntries); + string[] parts = line.ToLower().Split(punctuation, StringSplitOptions.RemoveEmptyEntries); int equal = 0; foreach (string word in parts) if (word[0] == word[word.Length - 1]) diff --git a/Lab4.RemoveComments/Program.cs b/Lab4.RemoveComments/Program.cs index 5e8d41e..f789a14 100644 --- a/Lab4.RemoveComments/Program.cs +++ b/Lab4.RemoveComments/Program.cs @@ -1,4 +1,5 @@ -using System; +using System; +using System.Text.RegularExpressions; namespace Lab4.RemoveComments {