1
0

feat: handle edge case when last and first have different casing

This commit is contained in:
Rokas Puzonas 2021-11-22 01:37:06 +02:00
parent b4b0afba32
commit eaed3f058f
2 changed files with 4 additions and 4 deletions

View File

@ -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])

View File

@ -1,4 +1,5 @@
using System;
using System;
using System.Text.RegularExpressions;
namespace Lab4.RemoveComments
{