using System; using System.Text.RegularExpressions; namespace Mustache { /// /// Provides utility methods that require regular expressions. /// public static class RegexHelper { private const string Key = @"[_\w][_\w\d]*"; internal const string CompoundKey = Key + @"(\." + Key + ")*"; /// /// Determines whether the given name is a legal identifier. /// /// The name to check. /// True if the name is a legal identifier; otherwise, false. public static bool IsValidIdentifier(string name) { if (name == null) { return false; } Regex regex = new Regex("^" + Key + "$"); return regex.IsMatch(name); } } }