Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Sample Regular Expressions

Posted by admin (Graham Ellis), 10 August 2002
I thought you might find these useful ... they're all written using Perl style regular expressions ....

To match an email address


To match a UK Postcode


To match an American Zip code


To match a date (UK Style)


To match a time


To match a complete URL for a web page


To match a Visa number


To match a Mastercard number


To match a UK Phone number


To match a UK car registration plate
       /\b[A-Z]{2}(?:51|02|52)[A-Z]{3}\b/      # current series
       /\b[A-HJ-NP-Y]\d{1,3}[A-Z]{3}\b/        # previous series
       /\b[A-Z]{3}\d{1,3}[A-HJ-NP-Y]\b/        # previous series
       /\b(?:[A-Z]{1,2}\d{1,4}|[A-Z]{3}\d{1,3})\b/     # old series - letters first
       /\b(?:\d{1,4}[A-Z]{1,2}|\d{1,3}[A-Z]{3})\b/     # old series - digits first

To match a UK national insurance number


To match a book's ISBN number



a) We've used non-capture groups throughout. You're free to use our expressions and add in extra brackets if you wish to extract parts of the match.
b) Some of these examples are fairly rudimentary tests, and it's up to you to check that they're suitable for use in your application
c) Many of these examples can only check that a string of text is in the correct format - there's no way that we can check if a particular car registartion was issued, unless of course we have access to the DVLC database.

This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho