Попробуйте вместо этого:
^([^,]+),\s([A-Z]{2})(?:\s(\d{5}))?$
Это выражение работает в обоих примерах, захватывает каждый фрагмент адреса в отдельные группы и правильно обрабатывает пробелы.
Вот как это ломается:
^ # anchor to the start of the string
([^,]+) # match everything except a comma one or more times
, # match the comma itself
\s # match a single whitespace character
([A-Z]{2}) # now match a two letter state code
(?: # create a non-capture group
\s # match a single whitespace character
(\d{5}) # match a 5 digit number
)? # this whole group is optional
$ # anchor to the end of the string