Yes, it follows the Perl syntax. The "p" in "preg" stands for Perl. The [man]PCRE[/man] manual page has info (PCRE = Perl Compatible Regular Expressions).
The vertical bar means bitwise OR in PHP, so that definitely won't work. It needs to be part of the regular expression.
Something like this:
preg_match( '/(\d{5}|\d{5}-\d{4})$/', $zipcode)
Or this:
preg_match( '/\d{5}(|-\d{4})$/', $zipcode)
The brackets are for specifying a group, the vertical bar seperates the allowed forms. In the second example, the first part of the group allows a blank string, the second part allows the "-1234".