Open this example in the interactive library
Source code
import re
print(bool(re.fullmatch(r'[A-Za-z_][A-Za-z0-9_]*', 'user_42')))Sample output
True

Validate a simple identifier. A self-contained example using the Python standard library.
Open this example in the interactive library
import re
print(bool(re.fullmatch(r'[A-Za-z_][A-Za-z0-9_]*', 'user_42')))True