
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How to write Python regular expression to check alphanumeric characters?
In Python there is a special sequence \w for matching alphanumeric and underscore when the LOCALE and UNICODE flags are not specified.
Example
import re result = re.search(r'^\w+$', 'Tutorials123') print result.group()
Output
Tutorials123
- Related Articles
- What is the Python regular expression to check if a string is alphanumeric?
- How to use special characters in Python Regular Expression?
- How to write a Python regular expression to use re.findall()?
- How to write a Python Regular Expression to validate numbers?
- How to write Python regular expression to match with file extension?
- How to split on successions of newline characters using Python regular expression?
- How to write a Python regular expression to get numbers except decimal?
- How to write a Python regular expression to match multiple words anywhere?
- How to write a case insensitive Python regular expression without re.compile?
- Write a Regular Expression to remove all special characters from a JavaScript String?
- How to match nonword characters in Python using Regular Expression?\n\n\n\n
- How to write Python Regular Expression find repeating digits in a number?
- How to write a Python regular expression that matches floating point numbers?
- Python - Check If All the Characters in a String Are Alphanumeric?
- How to write a regular expression to match either a or b in Python?

Advertisements