Does this look ok for a preg validation of US zip code?
I'm using a regex cookbook and forums to figure this out and I don't know if the syntax is off. It seems to catch wrong entries, but it also seems to be keeping valid entries from submitting too. This is the case with several validations I'm using (US zip, US phone, email etc).
Thoughts?
Code:
('/^[0-9]{5}([- ]?[0-9]{4})?$/', $string)
I'm using a regex cookbook and forums to figure this out and I don't know if the syntax is off. It seems to catch wrong entries, but it also seems to be keeping valid entries from submitting too. This is the case with several validations I'm using (US zip, US phone, email etc).
Thoughts?