“State or province” is one of the patterns that you can select on the Match panel. Use this pattern to make a field match the name or code of a state or province from a list of specific states or all states from specific countries.
You could use this pattern to check whether a valid US state name or abbreviation was entered into the state field on an order form. RegexMagic makes it easy to restrict the pattern to only those states that you can actually ship to. In this example, we’ll exclude APO addresses.
Alabama AL Alberta AB
\A(?:Ala(?:(?:bam|sk)a)|Arizona|Arkansas|California|Colorado|Connecticut|Delaware|District of Columbia|Florida|Georgia|Hawaii|Idaho|Illinois|Indiana|Iowa|Kansas|Kentucky|Louisiana|Maine|Maryland|Massachusetts|Michigan|Minnesota|Miss(?:(?:issipp|our)i)|Montana|Nebraska|Nevada|New (?:Hampshire|Jersey|Mexico|York)|North (?:(?:Carolin|Dakot)a)|Ohio|Oklahoma|Oregon|Pennsylvania|Rhode Island|South (?:(?:Carolin|Dakot)a)|Tennessee|Texas|Utah|Vermont|Virginia|Washington|West Virginia|Wisconsin|Wyoming|A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])\z
Required options: Case insensitive; Exact spacing.
Unused options: Dot doesn’t match line breaks; ^$ don’t match at line breaks; Numbered capture.
Alabama AL Alberta AB
If the RegexMagic pattern for states and provinces does not support your country, you can use the “list of literal text” pattern. Type or paste in the list of states or provinces for your country and the pattern will match any one of them.