Name

RegExp — NN 4 IE J3 ECMA n/a

Synopsis

The RegExp object is a static object that both generates instances of a regular expression and monitors all regular expression in the current window or frame. Instances of the RegExp object are covered in the regular expressions object description that follows this section.

Regular expressions assist in locating text that matches patterns of characters or characteristics. For example, a regular expression can be used to find out very quickly if an entry in a text field is a five-digit number. Defining the pattern to match requires knowledge of a separate notation syntax that is beyond the scope of this book (but is covered in Mastering Regular Expressions, by Jeffrey E.F. Friedl, published by O’Reilly). A summary of the syntax can be found in the description of the regular expression object.

Properties of the RegExp object store information about the last operation of any regular expression in the document. Therefore, it is conceivable that each property could change after each regular expression operation. Such operations include not only the methods of a regular expression object instance (exec() and test()), but also the String object methods that accept regular expressions as parameters (match(), replace(), and split()). Some of these properties are passed to the regular expression object as well, in preparation for the next operation with the regular expression.

All properties have verbose names as well as shortcut names that begin ...

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.