/// <summary>
/// Generates regexes to match the templates from the template list.
/// Supports templates with Template: or Msg: at the start
/// Does not process nested templates
/// </summary>
private void RefreshRegexes()
{
Regexes.Clear();
// derive optional template namespace prefixes to allow
string templ = Variables.NamespacesCaseInsensitive[Namespace.Template];
if (templ[0] == '(')
{
templ = "(?:" + templ.Insert(templ.IndexOf(')'), "|[Mm]sg") + @")?\s*";
}
else
{
templ = @"(?:" + templ + @"|[Mm]sg:|)\s*";
}
foreach (string s in TemplateList)
{
if (string.IsNullOrEmpty(s.Trim()))
{
continue;
}
Regexes.Add(new Regex(@"\{\{\s*" + templ + Tools.CaseInsensitive(Regex.Escape(s)) + @"\s*(\|[^\}]*|)}}",
RegexOptions.Singleline), @"{{subst:" + s + "$1}}");
}
}