using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @" \b
((?<CASE_UPPER>[[:upper:]]+)|
(?<CASE_INITIALCAPS>[A-Z][a-z]+[A-Z]*+)|
(?<CASE_MIXED>[A-z]*[A-Z][A-z]*+)|
(?<PHRASE>[A-Z][\w-]*(\s+[A-Z][\w-]*)+))
\b";
string input = @"I am testing to see if this works for UPPERCASE, InitialCase and mixedCase which of course is also mIxedcase. Firstword initial case should not be matched. FirstWordMixed case should be. UPPERCASE first word should be. And of course phrases that combine any combination of UPPER mixEd Initicase should be pulled as a phrase not a word which could be of course Initcase1 Initcase2 Initcase3. Finally it needs to match all sorto of Associations such as Association of First Words, Last Word for Association, Middle Word Association for Words.";
RegexOptions options = RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace;
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