devxlogo

September 28, 2002

Determine whether a string is lowercase

Here’s a quick-and-dirty method to determine whether a string contains only lowercase characters ‘ the string to test is in the SOURCE variableIf System.Text.RegularExpressions.Regex.IsMatch(source, “^[a-z]+$”) Then Console.WriteLine(“Lowercase string”)End If If

Determine whether a string is uppercase

Here’s a quick-and-dirty method to determine whether a string contains only uppercase characters ‘ the string to test is in the SOURCE variableIf System.Text.RegularExpressions.Regex.IsMatch(source, “^[A-Z]+$”) Then Console.WriteLine(“Uppercase string”)End If If