Python: use re.prefixmatch() instead of re.match() from Python 3.15

Take this validation function: import re TRAIN_NUMBER_RE = re . compile ( r "\d {6} " ) # six digits def is_valid_train_number ( value : str ) -> bool : return bool ( TRAIN_NUMBER_RE . match ( value )) It looks reasonable, and it works for the intended cases: >>> is_valid_train_number ( "345071" ) True >>> is_valid_train_number ( "ABC123" ) False But, woah, it also accepts garbage suffixes: >>>…