How to check if string contain only lowercase letters in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main()
        {
            string s1 = "CSHARPNET13Java89Python";
            Console.WriteLine(Regex.IsMatch(s1, "^[A-Z]*$"));


            string s2 = "!**!***!";
            Console.WriteLine(Regex.IsMatch(s2, "^[A-Z]*$"));


            string s3 = "CSHARP 13 Java 89 Python";
            Console.WriteLine(Regex.IsMatch(s3, "^[a-z]*$"));


            string s4 = "CSHARPJavaPython";
            Console.WriteLine(Regex.IsMatch(s4, "^[a-z]*$"));


            string s5 = "csharpjavapython";
            Console.WriteLine(Regex.IsMatch(s5, "^[a-z]*$"));


            string s6 = "CSHARPJAVAPYTHON";
            Console.WriteLine(Regex.IsMatch(s6, "^[a-z]*$"));


            string s7 = "1230998";
            Console.WriteLine(Regex.IsMatch(s7, "^[a-z]*$"));
        }
    }
}


/*
run:
  
False
False
False
False
True
False
False
   
*/

 



answered Oct 11, 2018 by avibootz

Related questions

...