Chapter 10.
Pattern Matching with Regular Expressions
A regular
expression is an object that describes a pattern of
characters. The JavaScript RegExp class represents regular
expressions, and both String and RegExp define methods that use
regular expressions to perform powerful pattern-matching and
search-and-replace functions on text.[1]
[1] The term
"regular expression" is an obscure one that dates back
many years. The syntax used to describe a textual pattern is indeed a
type of expression. However, as we'll see, that syntax is far
from regular! A regular expression is sometimes called a
"regexp" or even an "RE." JavaScript regular expressions were standardized in ECMAScript v3.
JavaScript 1.2 implements a subset of the regular expression features
required by ECMAScript v3, and JavaScript 1.5 implements the full
standard. JavaScript regular expressions are strongly based on the
regular expression facilities of the Perl programming language.
Roughly speaking, we can say that JavaScript 1.2 implements Perl 4
regular expressions, and JavaScript 1.5 implements a large subset of
Perl 5 regular expressions.
This chapter begins by defining the syntax that regular expressions
use to describe textual patterns. Then it moves on to describe the
String and RegExp methods that use regular expressions.
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.