txt2re is a great tool that can help you a lot when creating regular expressions. Just type in an example string you want to match, then use the selectors to create a snippet of code with the regex and validation process pre-populated, allowing you to drop the code straight into your application. This supports many languages including some of the following
- perl
- php
- python
- java
- javascript
- ruby
- c#
I must give some credit to my colleague for his blog post and also the full credit to Zoe Nolan.