HackerRank Python - Incorrect Regex




You are given a string S.
Your task is to find out whether S is a valid regex or not.



  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. import re
  3. for _ in range(int(input())):
  4. try:
  5. print(bool(re.compile(input())))
  6. except:
  7. print('False')




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube