+ 1

Help with Phone number Validator

#i have this code but i don´t know what is wrong with him import re #your code goes here pattern = r"^1|8|9*[0-9]*{0-8}*" if re.match(pattern, input()): print('Valid') else: print('Invalid')

3rd Aug 2021, 11:32 AM
Guadix Rogel
Guadix Rogel - avatar
2 ответов
+ 4
1. In your regular expression you are using {} wrong. Here you will find how to use it correctly: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Quantifiers 2. You are not restricting the length of a pattern Here is sequence I used to solve it: r"^[189][0-9]{7}
quot; which means it starts with 1 or 8 or 9 and then continued with exactly 7 digits 0 to 9
3rd Aug 2021, 12:13 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
Þhank you so much my men
4th Aug 2021, 8:02 AM
Guadix Rogel
Guadix Rogel - avatar