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
- Python Regex to extract maximum numeric value from a string
- Python Regex | Program to accept string ending with alphanumeric character
- Python | Lowercase first character of String
- Python - Lowercase Kth Character in string
- Python - Uppercase Nth character
- Replace values in Pandas dataframe using regex
- Program to check if a string contains any special character
- Python | Program that matches a word containing 'g' followed by one or more e's using regex
- Python program to find files having a particular extension using RegEx
- Python | Add only numeric values present in a list
- Python | Swap Name and Date using Group Capturing in Regex
- Parsing and Processing URL using Python - Regex
- Python Regex - Program to accept string starting with vowel
- Python program to read character by character from a file
- Python | Return lowercase characters from given string
- Find all the patterns of “1(0+)1” in a given string using Python Regex
- The most occurring number in a string using Regex in python
- Name validation using IGNORECASE in Python Regex
- Python - Substituting patterns in text using regex
- Categorize Password as Strong or Weak using Regex in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.