I am looking to match a string that is inputted from a website to check if is alpha-numeric and possibly contains an underscore. My code:
if re.match(\'[a-zA
Python has a special sequence \w for matching alphanumeric and underscore when the LOCALE and UNICODE flags are not specified. So you can modify your pattern as,
\w
LOCALE
UNICODE
pattern = '^\w+$'