Eyesis Home
  > Projects > PHP > REGEX Validation

PHP > REGEX Validation

With PHP's built in regular expression features we can create a syntax that will search through text and change cetain patterns. Check out Wikipedia's definition of Regular expression for more information.

If your interested in learning more about Regex, I recommend visiting Regular-Expressions.info. This is a excellent resource for anything related to regex.

Here is a couple regex samples I've found useful for validation:

Email Addresses

[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})

Postal Codes

[A-Z]{1}[0-9]{1}[A-Z]{1}[0-9]{1}[A-Z]{1}[0-9]{1}

See also

PHP manual on Regular Expression Functions