I'm trying to write a regex that follows these constraints:
- Exactly 5 digits
- Sometimes, but not always, followed by a dash with 4 more digits
- Zip code needs to be preceded by at least one whitespace
- Cannot be at the start of a text
I've arrived at this but it's not giving me the output I want:
r"^[A-Za-z].*\s.*\d{5}(?:[-\s]\d{4})?$"