import re from typing import Optional def recognize_pinpad_code(text: str) -> Optional[int]: if not text: return None match = re.search(r"\b\d{3}\b", text) return int(match.group()) if match else None