RE newbie question
Albert-Jan Roskam
sjeik_appie at hotmail.com
Wed Apr 18 15:54:23 EDT 2018
On Apr 18, 2018 21:42, TUA <kai.peters at gmail.com> wrote:
>
> 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?
Use a $ sign at the end of the regex
More information about the Python-list
mailing list