Python program to Count Uppercase, Lowercase, special character and numeric values using Regex
Prerequisites: Regular Expression in Python
Given a string. The task is to count the number of Uppercase, Lowercase, special character and numeric values present in the string using Regular expression in Python.
Input : "ThisIsGeeksforGeeks!, 123" Output : No. of uppercase characters = 4 No. of lowercase characters = 15 No. of numerical characters = 3 No. of special characters = 2
Approach: The re.findall(pattern, string, flags=0) method can be used to find all non-overlapping matches of a pattern in the string. The return value is a list of strings.
Below is the implementation.
The no. of uppercase characters is 4 The no. of lowercase characters is 15 The no. of numerical characters is 3 The no. of special characters is 4