using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^((u|is|has)\-[a-z0-9][a-zA-Z0-9]*|([A-Z][a-zA-Z0-9]*(__[a-z0-9][a-zA-Z0-9]*)?(--[a-z0-9][a-zA-Z0-9]*)?))$";
string input = @"is-state
is-State
is-stateActive2
u-utility
u-Utility
u-utilityClass2
has-child
has-Child
has-childClass2
his-child
a-child
1-child
A-child
js-test
Block
Block--mod
Block__el
Block__el--mod
BlockBox
BlockBox--modMod
BlockBox__elEl
BlockBox__elEl--modMod
block-box
Block-box
blockBox
5block
B__m--e
B__M--E
B__m--E
B__M--e
b__M--E
b__m--E
b__M--e
b__m--e
B__m__e
B--m--e
B--m__e
B_m-e
B-m_e
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx