I'm trying to make my code loop back to the beginning until the user inputs something that matches the REGEX
pattern.
For example:
userInput = raw_input('Enter text :')
if re.match("REGEX", userInput):
#Do something
If the REGEX
pattern does not match userInput, the code should ask them to enter userInput again until it matches the REGEX
and there forth will do something. I am assuming a for loop
is needed but I am not sure how to use it with REGEX
.
<<< UPDATE >>>
Solution thanks to VKS:
while True:
userInput = raw_input('Enter text :')
if re.match("REGEX", userInput):
break