1. Technology

Regular Expressions

By

Perhaps one of the hardest to understand of JavaScript statements for those new to JavaScript are those that use what are known as regular expressions. A number of different programming languages use regular expressions that involve almost identical constructs since this provide a very powerful matching tool.

This introduction gives a brief rundown of just how regular expressions can be used to perform whatever pattern matching that you require (for example an easy way of performing form field validation in many cases is to validate what is input against a regular expression pattern to see if the content at least appears to be valid for that field.

The easiest way of understanding regular expressions is to look separately at what each of the constructs that can be used in a regular expression means. Even the most complex of regular expressions can be easily understood by looking at the component parts of the expression and what each part means.

Once you understand how each of the parts of a regular expression works you can then use them in your JavaScript. The following summaries show you all the options that you have for use with regular expressions.

Finally to save you having to read through all of the above tutorials looking for the code for the particular pattern you need, here is a pattern reference that lists all of the codes you can use in regular expressions and what they mean.

  1. About.com
  2. Technology
  3. JavaScript
  4. Javascript Tutorials
  5. Regular Expressions

©2014 About.com. All rights reserved.