{"id":20787700,"url":"https://github.com/stemount/gov-uk-official-postcode-regex-helper","last_synced_at":"2026-03-10T19:32:48.627Z","repository":{"id":79724915,"uuid":"322337025","full_name":"stemount/gov-uk-official-postcode-regex-helper","owner":"stemount","description":"This repo contains the Gov.uk Postcode Regex which is probably the most accurate for UK postcodes","archived":false,"fork":false,"pushed_at":"2020-12-17T16:17:48.000Z","size":3,"stargazers_count":6,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T00:17:41.949Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stemount.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["stemount"]}},"created_at":"2020-12-17T15:33:22.000Z","updated_at":"2025-01-15T14:16:44.000Z","dependencies_parsed_at":"2023-05-15T19:45:26.965Z","dependency_job_id":null,"html_url":"https://github.com/stemount/gov-uk-official-postcode-regex-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stemount/gov-uk-official-postcode-regex-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemount%2Fgov-uk-official-postcode-regex-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemount%2Fgov-uk-official-postcode-regex-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemount%2Fgov-uk-official-postcode-regex-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemount%2Fgov-uk-official-postcode-regex-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stemount","download_url":"https://codeload.github.com/stemount/gov-uk-official-postcode-regex-helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stemount%2Fgov-uk-official-postcode-regex-helper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30350095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T14:59:16.053Z","updated_at":"2026-03-10T19:32:48.617Z","avatar_url":"https://github.com/stemount.png","language":null,"funding_links":["https://github.com/sponsors/stemount"],"categories":[],"sub_categories":[],"readme":"# GOV.UK Official Postcode Regex and Helpers\n\nThis repo contains the GOV.UK Postcode Regex which is a good place to start for UK Postcodes as this has been carefully considered by the GOV.UK team, ensuring it will match all valid UK Postcodes.\n\nThere will very likely existing solutions postcode regex available in your GraphQL/REST MVC API framework, but this project does not have these helpers yet [Issue #2](https://github.com/stemount/gov-uk-official-postcode-regex-helper/issues/2).\n\nThis would not be suitable if you wanted to localise postcode lookup to postcodes outside of the UK, there's already great things for that. Follow [Issue #6](https://github.com/stemount/gov-uk-official-postcode-regex-helper/issues/6) here.\n\n## Source\u003csup\u003e1\u003c/sup\u003e\n\n#### UK Postcode Regular Expression\n\nThe following is the UK Postcode Regular Expression and the corresponding detail explaining the logic behind the UK Postcode Regular Expression.\n\n###### 3.1 Expression\n\n`^([Gg][Ii][Rr] 0[Aa]{2})|((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A- Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z])))) [0-9][A-Za-z]{2})$`\n\n###### 3.2 Logic\n\n\"GIR 0AA\"\n- **OR**\n  - One letter followed by either one or two numbers\n  - One letter followed by a second letter that must be one of ABCDEFGHJ KLMNOPQRSTUVWXY (i.e..not I) and then followed by either one or two numbers\n- **OR**\n  - One letter followed by one number and then another letter\n- **OR**\n  - A two part post code\n    where the first part must be\n    One letter followed by a second letter that must be one of ABCDEFGH JKLMNOPQRSTUVWXY (i.e..not I) and then followed by one number and optionally a further letter after that\n  - **AND**\n  - The second part (separated by a space from the first part) must be One number followed by two letters.\n\nA combination of upper and lower case characters is allowed.\nNote: the length is determined by the regular expression and is between 2 and 8 characters.\n\n## Sources\n[1] [Page 3 of Bulk Transfer Validation](https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/488478/Bulk_Data_Transfer_-_additional_validation_valid_from_12_November_2015.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstemount%2Fgov-uk-official-postcode-regex-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstemount%2Fgov-uk-official-postcode-regex-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstemount%2Fgov-uk-official-postcode-regex-helper/lists"}