For anyone interested in root cause, the problem with the file is that there are non-breaking space characters (UNICODE 160) instead of normal (ASCII 32) space characters between the comma and the state code. This was causing the regular expression to fail and that's why the state codes were not printing. The original code from @leithross can be fixed in two ways...
1. Use \b instead of \s in the regular expressions to detect the word boundaries (as in the solution from @waterserv)
2. Use a regular expression to replace the non-breaking spaces with regular ones
Bookmarks