A regular expression that will allow a string with only one Capital Letter
Posted
by Phoenix
on Stack Overflow
See other posts from Stack Overflow
or by Phoenix
Published on 2010-04-08T19:55:22Z
Indexed on
2010/04/08
20:03 UTC
Read the original article
Hit count: 370
The string should be 6 - 20 characters in length. And it should contain 1 Capital letter.
I can do this in code using C#
string st = "SomeString"
Regex rg = new Regex("[A-Z]");
MatchCollection mc = rg.Matches(st);
Console.WriteLine("Total Capital Letters: " + mc.Count);
if (mc.Count > 1)
{
return false;
}
But what i really want is a Regular expression that will match my string if it only contains one capital. The string can start with a common letter and should have only letters.
Thanks In advance. (I did look at some of the other RegEx questions but they did not help).
© Stack Overflow or respective owner