I am trying to create a regex that matches a US state abbreviations in a string using python.
The abbreviation can be in the format:
CA
Ca
The string could be:
Boulder, CO 80303
Boulder, Co
Boulder CO
...
Here is what I have, which obviously doesn't work that well. I'm not very good with regular expressions and google didn't turn up much.
pat = re.compile("[A-Za-z]{2}")
st = pat.search(str)
stateAbb = st.group(0)