I admit regex is a strange world and I have not been able to really get my head wraped around it. But I have this problem that I believe belongs in the regex world. i would like to change last names like "o'brian" to "O'Brian" or "macdonald" to "MacDonald" or "who-knew" to "Who-Knew" or "who knew" to "Who Knew"
so far all I have is ....
setCaps("o'brian");
string setCaps(string s)
{
string result = Regex.Replace(s, @"\b[a-z]['a-z]\w+", delegate(Match match)
{
string ch = match.ToString();
return char.ToUpper(ch[0]) + ch.Substring(1);
});
return result;
}
Thanks