Incorrect Regex
-
Practice>Python>Errors and Exceptions>Incorrect Regexhackerrank.com 2019. 2. 25. 04:24
hackerrank.comIncorrect RegexProblem link : https://www.hackerrank.com/challenges/incorrect-regex/problemDifficulty : Easy TipProblem ask how to validate regular expressionJust call re.compile(), it will raise exception if the given regular expression is not valid Solution import re cnt = int(input()) for _ in range(cnt): try: re.compile(input()) print(True) except: print(False)