using System.Text.RegularExpressions; public class Kata { public static int SameCase(char a, char b) { string lowerCase = @"[a-z]"; string upperCase = @"[A-Z]"; string symbols = @"[^a-zA-Z]"; if ((Regex.IsMatch($"{a}", lowerCase) && Regex.IsMatch($"{b}", lowerCase)) ||(Regex.IsMatch($"{a}", upperCase) && Regex.IsMatch($"{b}", upperCase))) { return 1; } else if (Regex.IsMatch($"{a}", symbols) || Regex.IsMatch($"{b}", symbols)) { return -1; } else { return 0; } } }
- using System.Text.RegularExpressions;
- public class Kata {
- public static int SameCase(char a, char b) {
string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";char tempA = a;char tempB = b;if((!letters.Contains(tempA = char.ToUpper(tempA)) && letters.Contains(tempB = char.ToUpper(tempB))) ||(!letters.Contains(tempB = char.ToUpper(tempB)) && letters.Contains(tempA = char.ToUpper(tempA))) ||(!letters.Contains(tempA = char.ToUpper(tempA)) && !letters.Contains(tempB = char.ToUpper(tempB)))) return -1;if(char.IsUpper(a) && char.IsUpper(b)){return 1;} else if (char.IsLower(a) && char.IsLower(b)){return 1;} else {return 0;}- string lowerCase = @"[a-z]";
- string upperCase = @"[A-Z]";
- string symbols = @"[^a-zA-Z]";
- if ((Regex.IsMatch($"{a}", lowerCase) && Regex.IsMatch($"{b}", lowerCase))
- ||(Regex.IsMatch($"{a}", upperCase) && Regex.IsMatch($"{b}", upperCase)))
- {
- return 1;
- }
- else if (Regex.IsMatch($"{a}", symbols) || Regex.IsMatch($"{b}", symbols))
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
- }