4
0
mirror of https://github.com/art-ist/mustache-sharp.git synced 2024-06-16 21:05:32 +00:00
MustacheSharp/mustache-sharp/RegexHelper.cs
Travis Parks f8628aaf86 Implement custom tags.
This is the first step towards supporting custom tags. There are
wrinkles I need to work out, since I'm not 100% sure what the finished
code will look like.
2013-01-08 21:33:53 -05:00

23 lines
689 B
C#

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