Test string S. S must be of length, greater than or equal to 5. First char is lowercase alphabet. Second char is positive digit. Third char is not lowercase alphabet. Fourth char is not uppercase alphabet. Fifth char is uppercase alphabet.
import re
Regex_Pattern = r"^[a-z][0-9][^a-z][^A-Z][A-Z]"
print(str(bool(re.search(Regex_Pattern, input()))).lower())
Why, using this piece of code, can't I match the string: a0$?ZWe to print False instead of printing True?
Falsewhen it matches the regex? Perhaps you meant to callloweron theinputrather than on the result ofstr(bool(...))?Falseinstead ofTrue. I meana0$?ZWedoesn't match. My mistake.0to be a positive digit. In that case change[0-9]to[1-9].