How can I make a regex match the entire string? August 4, 2023 by Tarik Try with specifying the start and end rules in your regex: re.compile(r'^test-\d+$')