RE newbie question

TUA kai.peters at gmail.com
Wed Apr 18 15:37:29 EDT 2018


import re

compval = 'A123456_8'
regex = '[a-zA-Z]\w{0,7}'

if re.match(regex, compval):
   print('Yes')
else:
   print('No')  


My intention is to implement a max. length of 8 for an input string. The above works well in all other respects, but does allow for strings that are too long.

What is the proper way to fix this?

Thanks for any help!



More information about the Python-list mailing list