To match a Customer PO Number that is comprised of two alpha numeric characters, followed by five digits, followed by a "P", "S" or "D", when each of the three components has an optional hyphen between them.
[0-9A-Z] Matches a digit or letter, so [0-9A-Z]{2} would match exactly 2 digits or letters.
Remember, when a question mark follows an item, it means that either zero or one of the preceding things occur, so [0-9A-Z]{2}-? matches exactly two digits or letters with or without a trailing hyphen.
Continuing in this way, we would arrive at:
[0-9A-Z]{2}-?[0-9]{5}-?[PSD]
Then we need the two anchors ( ^ and $ ) to indicate this must appear at both the beginning and the end of the string (and therefore be equal to the string), and the slashes to denote that we are entering a regular expression (instead of trying to match this strange literal):
/^[0-9A-Z]{2}-?[0-9]{5}-?[PSD]$/