Task from the book. Write a regular schedule that checks the string variable's compliance with the rule:
- there is at least one uppercase letter
- there is at least one lowercase letter
- these 2 characters go in a row, the order does not matter
For simplicity, we assume that the strings do not contain strings.
I wrote something like this: /[az]*[AZ]+[az]*/ or /[az]*[AZ]+[az]+/
It is proposed to test on lines like "fred" , "Fred" and "frEd" . I found one word with which this template does not match, it is "freD" . How to generalize the regular list to all possible strings?
The answer in the book about the pearl is even worse than my decision.
(?=.*?[az]+).*?[AZ]+- Mike