Last active
March 5, 2023 03:46
-
-
Save benbalter/6147066 to your computer and use it in GitHub Desktop.
Regular expression to find government domains for websites / email addresses
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
# regex to match government emails. Should detect: | |
# foo.gov, foo.mil | |
# foo.gov.uk, foo.mil.uk | |
# foo.fed.us | |
# foo.govt.nz, foo.gc.ca, foo.guv.ro, gub.uy | |
# note: foo.gouvt, foo.gc, foo.fed.uk, etc. will technically pass, but they are invalid domains | |
regex = /(\.g[ou]{1,2}(v|b|vt)|\.mil|\.gc|\.fed)(\.[a-z]{2})?$/i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment