PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
everything in the () is a subpattern of the regular expression the ? means that it must match this pattern either 0 or 1 times, so
([-]?[0-9]{4})? ... means that it must match the - 0 or 1 times followed by 4 digits of 0-9. with that whole subpattern being match 0 or 1 times, the $ at the very end means that there is nothing after.