ABB.Swum.Tests.PerformanceTests.CamelIdSplitter.Split C# (CSharp) Method

Split() public method

public Split ( string identifier ) : string[]
identifier string
return string[]
            public override string[] Split(string identifier)
            {
                //do initial conservative split
                var words = base.Split(identifier);
                var result = new List<string>();
                //search for any words that start with two or more uppercase letters, followed by one or more lowercase letters
                foreach (var word in words)
                {
                    var m = Regex.Match(word, @"^(\p{Lu}+)(\p{Lu}\p{Ll}+)$");
                    if (m.Success)
                    {
                        //regex matches, split and add each part
                        result.Add(m.Groups[1].Value);
                        result.Add(m.Groups[2].Value);
                    }
                    else
                    {
                        result.Add(word);
                    }
                }

                return result.ToArray();
            }
        }
PerformanceTests.CamelIdSplitter