Check Alphanumeric Characters Using Python Regular Expression



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
Updated on: 2020-02-20T05:51:30+05:30

368 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements