I am trying to make a regex to match simple addresses like
123 Main Street
Simpleville, VA 12345
I have little experience with regex's and through reading and lots of messing around I have come up with.
While this can get many false positives it seems to work well enough in most cases since the state abbreviation has to be uppercase. The problem I am having it matching the zipcode too. What I did was attach \d{5}? to the end of that regex but that just caused the whole regex to fail. Shouldn't the ? mean that it will optionally match 5 digits if it sees them? Thanks.
123 Main Street
Simpleville, VA 12345
I have little experience with regex's and through reading and lots of messing around I have come up with.
Code:
/(\d{1,5}).*\b(A[LKSZRAP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])\b/gm
Comment