import re
def regex_validation(pattern, input_string):
"""
Function to check the validation of a regular expression pattern against an input string.
Returns True if the input string matches the pattern, False otherwise.
"""
try:
# Compile the pattern into a regular expression object
regex = re.compile(pattern)
except re.error as e:
print(f"Error in regex pattern: {e}")
return False
# Check if the input string matches the pattern
if regex.fullmatch(input_string):
return True
else:
return False
# Example usage
pattern = r'^[a-zA-Z]+$' # Example pattern: only alphabets
input_string = 'abcde' # Example input string
result = regex_validation(pattern, input_string)
print(result)