# Write a Python program to Check if String Contain Only Defined Characters using Regex # _importing moduleimport re    def check(str, pattern):        # _matching the strings    if re.search(pattern, str):        print("Valid String")    else:        print("Invalid String")  # _driver codepattern = re.compile('^[1234]+$')check('2134', pattern)check('349', pattern)