Regular expressions are often used for data validation together with PHP, JavaScript and other programming languages. This examples below will show you real world regex patterns which can be used in PHP with function like preg_match() other PHP functions. If you need more information about particular regular expression try a search about "regex" inside Google. There are many more examples.

Use the form button and check for each pattern if some kind of value is valid or not. This is just a regex example, there is much more you can do with regular expressions.

DigitalOceanSSD Cloud Server from $5/month by DigitalOcean, simple cloud hosting, built for developers. Receive $10 in credits »
ServerPilotServerPilot is the best way to run WordPress and PHP sites on your DigitalOcean servers. First month free »

All patterns are optimized to use with the PHP function preg_match (note the leading and the trailing slash).


This decimal check allows a decimal number with max 5 digits before the "." and 1 or 2 decimals.


Dutch postal code

This postal code is a combination of four numbers and 2 letters (f.e. 1000 AB). With this pattern its allowed to use caps and small caps and a single space or not between numbers and letters.


E-mail address

This example checks real world e-mail addresses, but the pattern is limited to the lack of knowledge about the domain names and users. But the pattern takes care about unallowed characters and combinations.