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.

MoosendMoosend, the All-in-One marketing platform your business deserves. Start free today »
CloudwaysCloudways The Ultimate Managed Cloud Hosting Platform. Start Your Free Trial » No Credit Card Required.

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

Decimals

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

/^[1-9]{1}([0-9]{0,5})?\.[0-9]{1,2}$/

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.

/^[1-9]{1}[0-9]{3}\s?[a-zA-Z]{2}$/

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.

/^[\w-]+(\.[\w-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/i