Created
May 12, 2016 22:21
-
-
Save jrunning/1a881b50ce00977b853fae0504e1658c to your computer and use it in GitHub Desktop.
A regular expression that matches every US state or territory's name or postal abbreviation (I think)?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
expr = /^( | |
a( | |
[ksz] | | |
( | |
l(abam|ask)? | | |
rizon | |
)a | | |
merican\ssamoa | | |
r(kansas)? | |
) | | |
c( t | | |
a(lifornia)? | | |
o(lorado|onnecticut)? | |
) | | |
d( c | | |
e(leware)? | | |
istrict\sof\scolumbia | |
) | | |
fl(orida)? | | |
gu(am)? | | |
h(awai)?i | | |
i( n | | |
d(aho)? | | |
l(linois)? | | |
(ndian|ow)?a | |
) | | |
k( | |
(ansa)?s | | |
(entuc)?y | | |
) | | |
m( | |
[edsntp] | | |
a(ine|ryland|ssachusetts)? | | |
i( | |
chigan | | |
ss(issipp|our)i | | |
nnesota | |
)? | | |
o(ntana)? | |
) | | |
n( | |
[vhjmycd] | | |
e( | |
(brask|vad)a | | |
w\s(hampshire|jersey|mexico|york) | |
)? | | |
orthern\smariana\sislands | |
) | | |
(nor|sou)th\s(carolin|dakot)a | | |
o( | |
h(io)? | | |
k(lahoma)? | | |
r(egon) | |
) | | |
p( r | | |
(ennsylvani)?a | | |
uerto\srico | |
) | | |
r(i|hode island) | | |
s[cd] | | |
t( | |
[nx] | | |
e(nnessee|xas) | |
) | | |
u( m | | |
nited\sstates\sminor\soutlying\sislands | | |
t(ah)? | |
) | |
v( | |
(ermon)?t | | |
i(rgin\sislands)? | |
) | | |
w( | |
[avi] | | |
(ashingto|isconsi)n | | |
y(oming)? | |
) | | |
( v | | |
l(ouisian)? | | |
g(eorgi)? | | |
(west\s)?virgini | |
)a | |
)$/ix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment