How to write Python regular expression to check alphanumeric characters?

PythonServer Side ProgrammingProgramming

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
raja
Published on 10-Jan-2018 14:05:48
Advertisements