+ 1
What is error in "phone Number validation ". it failed 4th case.
import re def isValid(s): # 1) Begins with 1 or 8 or 9 # 2) Then contains 8 digits Pattern = re.compile(r"^(1/8/9)?[8]") return Pattern.match(s) # Code s = input() if (isValid(s)): print ("Valid") else : print ("Invalid")
3 Respuestas
+ 2
Maybe repeat the chapter to understand the syntax.
Use [] for sets of characters and {} for quantification (also ? + *)
+ 1
Starts with 1, 8 or 9: ^[189]
Contains 8 digits (=7 more) : [0-9]{7}
Then it should end: $
0
There will be needed the end with 8 digits. You can first test your code on the Playground and see what happend. This can be done with printing of few variables.
https://code.sololearn.com/cx1tfbykB3pp/?ref=app