Team LiB
Previous Section Next Section

Chapter 8: Regular Expressions

Overview

Manipulation of textual data is a common task in JavaScript. Checking data entered into forms, creating and parsing cookies, constructing and modifying URLs, and changing the content of Web pages can all involve complicated operations on strings. Text matching and manipulation in JavaScript is provided by the String object, as discussed in Chapter 7, and regular expressions, a feature enabling you to specify patterns of characters and sets of strings without listing them explicitly.

Regular expressions, sometimes referred to as regexps or regexes for brevity, have also long been a part of many operating systems. Readers unfamiliar with UNIX tools like grep, sed, awk, and Perl might find regular expressions odd at first but will soon recognize their utility. If you have ever used the dir command in DOS or ls command in UNIX, chances are you've used “wildcard” characters such as * or ?. These are primitive regular expressions! Readers who have worked in more depth with regular expressions, especially with Perl, will find JavaScript regexps very familiar.

This chapter is an introduction to JavaScript's RegExp object. It covers basic syntax, common tasks, and more advanced applications of regular expressions in your scripts.


Team LiB
Previous Section Next Section