0

I'm learning regex re.match recently, here's the code: re.match(r"^[a-z]{2}\d{2}$", something), my understanding is:

[a-z]{2} matches two lower letters

Then what does the rest \d{2}$ mean? Thanks.

wawawa
  • 2,255
  • 2
  • 23
  • 61
  • 2
    See https://regex101.com/r/BI9KZE/1 – Wiktor Stribiżew Apr 19 '22 at 15:41
  • 1
    Your regular expression matches the beginning of the string (`^`) followed by two (`{2}`) lowercase letters (`[a-z]`) followed by two (`{2}`) digits (`\d`) followed by the end of the string (`$`). `[a-z]` is a *character class* that matches any lowercase letter. – Cary Swoveland Apr 19 '22 at 16:29

0 Answers0