+ 2
What's wrong with this phone number validator regex?
This is the task: You are given a number input, and need to check if it is a valid phone number. A valid phone number has exactly 8 digits and starts with 1, 8 or 9. Output "Valid" if the number is valid and "Invalid", if it is not. What is wrong with the following regex? import re number = input() pattern = r"^1|8|9\d{8}
quot; if re.match(pattern, number): print("Valid") else: print("Invalid")2 Respostas
+ 9
^(1|8|9)\d{7}$
start with 1 or 8 or 9 , next 7 digit
+ 2
Thank you Roland 🙏