In this HackerRank Incorrect Regex problem solution you are given a string and we need to find out whether S is a valid regex or not.

HackerRank Incorrect Regex in python problem solution

HackerRank Incorrect Regex in python problem solution

import re

number_of_test_cases = int(raw_input())

for test_case in range(number_of_test_cases):
    try:
        regex_pattern = raw_input().strip()
        regex_error_test = re.sub(regex_pattern, "", "testing")
        print True

    except re.error as e:
        print False