Appendix. Regular expressions

 

In JavaScript, a regular expression is a JavaScript object that describes a pattern of characters. It’s used to match strings or parts of strings and for search and replace operations. jQuery uses regular expressions extensively for such diverse applications as parsing selector expressions, determining the type of browser in use, and trimming whitespace from text.

The use of regular expressions in JavaScript is an important part of using the language effectively. Regular expressions appear in many of the plugins in this book to test values or to break up strings into their component parts. You should be familiar with their syntax and usage patterns.

Online resources

More information on, and examples of, JavaScript regular expressions are available on the web. The following list contains a few of the many references and tutorials on this subject:

Regular expression basics

You can create a regular expression using the RegExp function

var re = new RegExp(pattern, modifiers);

or by using its literal form:

var re = /pattern/modifiers;

Regular expression syntax

 
 
 
 

RegExp functions

 

String functions

 
 

Usage patterns

 
 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest