[Python] Understanding and Fixing the regex?

Discussão em 'Python' iniciado por Stack, Fevereiro 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a regex on my input parameter:

    r"^(ABC-\d{2,9})|(ABz?-\d{3})$"


    Ideally it should not allow parameters with ++ or -- at the end, but it does. Why is the regex not working in this case but works in all other scenarios?

    ABC-12 is a valid.
    ABC-123456789 is a valid.
    AB-123 is a valid.
    ABz-123 is a valid.

    Continue reading...

Compartilhe esta Página