Make extensive use of raw string literals C#11 feature

This commit is contained in:
Kwoth
2023-01-21 01:12:11 +01:00
parent 0fe4f14d96
commit 63a9ae2dac
32 changed files with 756 additions and 587 deletions

View File

@@ -78,13 +78,13 @@ public class TriviaQuestion
private static string Clean(string str)
{
str = " " + str.ToLowerInvariant() + " ";
str = Regex.Replace(str, "\\s+", " ");
str = Regex.Replace(str, "[^\\w\\d\\s]", "");
str = Regex.Replace(str, @"\s+", " ");
str = Regex.Replace(str, @"[^\w\d\s]", "");
//Here's where custom modification can be done
str = Regex.Replace(str, "\\s(a|an|the|of|in|for|to|as|at|be)\\s", " ");
str = Regex.Replace(str, @"\s(a|an|the|of|in|for|to|as|at|be)\s", " ");
//End custom mod and cleanup whitespace
str = Regex.Replace(str, "^\\s+", "");
str = Regex.Replace(str, "\\s+$", "");
str = Regex.Replace(str, @"^\s+", "");
str = Regex.Replace(str, @"\s+$", "");
//Trim the really long answers
str = str.Length <= MAX_STRING_LENGTH ? str : str[..MAX_STRING_LENGTH];
return str;