Skip to content

Instantly share code, notes, and snippets.

@gyrus
Created October 9, 2015 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyrus/71ab184d98d19ab9f5a1 to your computer and use it in GitHub Desktop.
Save gyrus/71ab184d98d19ab9f5a1 to your computer and use it in GitHub Desktop.
Regular expression to match a UK postcode
<?php
preg_match( '/([A-Za-z]{1,2}[0-9]{1,2})[\s]*([0-9][A-Za-z]{2})/', 'WC1N 3XX', $matches );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment