0

Regular expression

Please can someone help me with this; import re #your code goes here user_input = input() pattern = re.compile(r'[189]\d{7}') if pattern.match(user_input): print('Valid') else: print('Invalid') I keep failing the 3rd test case( and I don't know why).

17th Nov 2020, 2:23 PM
Light
Light - avatar
2 Respuestas
+ 3
You need start "^" and end anchors "
quot; (specially end for match), so it won't match strings like "81234567egg"
17th Nov 2020, 2:37 PM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
CarrieForle Thanks alot. My mind was totally off that 👍
17th Nov 2020, 2:39 PM
Light
Light - avatar