// that make sure the words to match are separated by spaces or punctuation.
// NOTE: The reason why we don't use \b tags is that \b doesn't match reverse slash characters "\" so
// a pre-sanitized (see 1.) string like "\[test]" wouldn't get picked up by the \b.
- if (keyword.Count(c => (c == '"')) > 0)
+ if (keyword.Any(c => c == '"'))
{
// Matches the last double quote character.
- keyword = Regex.Replace(keyword, "\"$", "(?!\\w)");
+ keyword = StartDoubleQuote.Replace(keyword, "(?!\\w)");
// When matching for the first double quote character we also consider the possibility
// of the double quote being preceded by a @ character.
- keyword = Regex.Replace(keyword, "^\"|(?<=^@)\"", "(?<!\\w)");
+ keyword = EndDoubleQuote.Replace(keyword, "(?<!\\w)");
}
- // Make sure any name tagged as ours gets highlighted only when others say it.
- keyword = StartAtSign.Replace(keyword, "(?<=(?<=/name.*)|(?<=,.*\"\".*))");
+ // Make sure the character's name is highlighted only when mentioned directly (eg. it's said by someone),
+ // for example in 'Name Surname says, "..."' 'Name Surname' won't be highlighted.
- keyword = Regex.Replace(keyword, "^@", @"(?<=(?<=,.*"".*)|(?<!\[Name].*))");
++ keyword = StartAtSign.Replace(keyword, @"(?<=(?<=,.*"".*)|(?<!\[Name].*))");
_highlights.Add(keyword);
}