xxxxxxxxxx
# Example from https://docs.python.org/3/howto/regex.html
import re
p = re.compile('ab*')
p.match(input1)
xxxxxxxxxx
import re
test_string = 'a1b2cdefg'
matched = re.match("[a-z][0-9][a-z][0-9]+", test_string)
is_match = bool(matched)
print(is_match)
xxxxxxxxxx
import re
regExPattern = re.compile("[0-9]")
input1 = "5"
if not re.fullmatch(regExPattern, input1):
print("input is not a single digit")
xxxxxxxxxx
import re
# Define the pattern
pattern = r'^[a-zA-Z0-9]+$'
# Define the string to check
string_to_check = 'AbCdEf123'
# Check if the string matches the pattern
match = re.match(pattern, string_to_check)
# Print the result
if match:
print("String matches the pattern")
else:
print("String does not match the pattern")